Mirroring CPAN by inclusion declaration rather than by exclusion
3 direct replies — Read more / Contribute
|
by Intrepid
on Nov 08, 2024 at 16:14
|
I'd like to mirror a hierarchy of Perl modules from CPAN: everything in ExtUtils:: but nothing else. Like a mini-cpan but not. Minicpan provides for exclusion of modules matching a regex but afaict provides no way to say "exclude everything except this".
Does anyone have knowledge of an existing script for something like this?
Thanks for your attention to this rather odd query.
Nov 08, 2024 at 20:55 UTC
Examine what is said, not who speaks.
Love the truth but pardon error.
Silence betokens consent.
In the absence of evidence, opinion is indistinguishable from prejudice.
|
Trouble usig a subroutine from a custom module
2 direct replies — Read more / Contribute
|
by fritz1968
on Nov 08, 2024 at 12:34
|
I was hoping that someone can help me with this issue. I was able to create a use custom Perl modules from my previous employment, but am having an issue at this new job. Unlike the old job, I am not using the server version of perl, but instead, installed a local version to my home directory.
In this directory (/home/myhomedrive/script/prog1) I have this program called dupCheck.pl:
#!/home/myhomedrive/opt/perl/bin/perl
#use strict;
use warnings;
use lib '/home/myhomedrive/scripts/lib';
use customPerlMod;
my $string = " ll ";
$string = trim ( $string );
As you can see from the code above, I have the custom module here: /home/myhomedrive/scripts/lib
Here is a snippet of my custom module (I have several different subroutines in it, but for the purposes of this question, I am showing only a few pieces of code):
#!/home/myhomedrive/opt/perl/bin/perl
package customPerlMod;
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($)
{
my $string = shift;
$string =~ s/^\s+//;
return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($)
{
my $string = shift;
$string =~ s/\s+$//;
return $string;
}
1;
when I run the program, I get this at the command prompt:
./dupCheck.pl
Undefined subroutine &main::trim called at ./dupCheck.pl line 20, <DAT
+A> line 960.
any idea what I am doing wrong?
|
Entity statistics
1 direct reply — Read more / Contribute
|
by LexPl
on Nov 08, 2024 at 08:07
|
Hi,
I'm a Perl newbie. My aim is to generate a statistics that lists the number of occurrences for each member of a large group of regex patterns in an xml file. These patterns often also contain ISO entities. I would be very obliged if you could give me your advice to start on this endeavour.
Examples of such patterns would be "§\s*[0-9])" or "Art\.\s*[0-9IVX]".
Many thanks in advance!
|
exists(&subname) causes strange autovivification problem
2 direct replies — Read more / Contribute
|
by jimav
on Nov 05, 2024 at 18:09
|
With "no autovivification" in effect, using "exists &subname" causes strange behavior:
perl -E '
no autovivification;
my @ary;
push @ary, exists(&nonesuch);
say scalar(@ary)
'
# RESULT: 0
perl -E '
no autovivification;
my @ary;
push @ary, [ exists(&nonesuch) ];
say scalar(@ary)
'
# RESULT: Modification of a read-only value attempted at -e line 5
What's going on here? I don't think exists(&subname) should "autovivify" anything. The docs for 'exists' say
"Mentioning a subroutine name for exists or defined does not count as declaring it."
I'm using Perl v5.38.2
|