$ PERL_CORE=1 ./perl lib/Net/t/hostname.t
1..2
not ok 1
Use of uninitialized value in string eq at lib/Net/t/hostname.t line 39.
Use of uninitialized value in string eq at lib/Net/t/hostname.t line 39.
ok 2
With the patch the test's logic is identical, but now it doesn't warn:
$ PERL_CORE=1 ./perl lib/Net/t/hostname.t
1..2
not ok 1
ok 2
(@dummy is never used - it's just there to make sure the grep doesn't run in
void context)
Nicholas Clark
--
Even better than the real thing: http://nms-cgi.sourceforge.net/
--- lib/Net/t/hostname.t.orig Mon Dec 3 22:56:11 2001
+++ lib/Net/t/hostname.t Sat Aug 24 11:22:15 2002
@@ -36,7 +36,7 @@ else {
my @domain = qw(foo.example.com bar.example.jp);
my @copy = @domain;
-my @dummy = grep { hostname eq $_ } @domain;
+my @dummy = grep { hostname && $_ } @domain;
($domain[0] && $domain[0] eq $copy[0])
? print "ok 2\n"
Thanks, applied (#17765).
Were we not previously comparing the returned value?
>
> ($domain[0] && $domain[0] eq $copy[0])
> ? print "ok 2\n"
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/
> >--- lib/Net/t/hostname.t.orig Mon Dec 3 22:56:11 2001
> >+++ lib/Net/t/hostname.t Sat Aug 24 11:22:15 2002
> >@@ -36,7 +36,7 @@ else {
> > my @domain = qw(foo.example.com bar.example.jp);
> > my @copy = @domain;
> >
> >-my @dummy = grep { hostname eq $_ } @domain;
> >+my @dummy = grep { hostname && $_ } @domain;
>
> Were we not previously comparing the returned value?
No. Before patch the test was:
# This check thats hostanme does not overwrite $_
my @domain = qw(foo.example.com bar.example.jp);
my @copy = @domain;
my @dummy = grep { hostname eq $_ } @domain;
($domain[0] && $domain[0] eq $copy[0])
? print "ok 2\n"
: print "not ok 2\n";
Nicholas Clark
Well code is sill very obscure. What is testing that $_ isn't overwritten
there? - it is testing that value that is aliased to $_ is not overwritten.
And as all values in list are "true" then why is new code not
grep { hostname && 1 } @domain;
or
grep { hostname } @ domain;
Or perhaps what is realy meant is
hostname foreach (@ domain);
>
>Nicholas Clark
> >No. Before patch the test was:
> >
> ># This check thats hostanme does not overwrite $_
> >my @domain = qw(foo.example.com bar.example.jp);
> >my @copy = @domain;
> >
> >my @dummy = grep { hostname eq $_ } @domain;
> >
> >($domain[0] && $domain[0] eq $copy[0])
> > ? print "ok 2\n"
> > : print "not ok 2\n";
>
> Well code is sill very obscure. What is testing that $_ isn't overwritten
> there? - it is testing that value that is aliased to $_ is not overwritten.
>
> And as all values in list are "true" then why is new code not
>
> grep { hostname && 1 } @domain;
> or
> grep { hostname } @ domain;
>
> Or perhaps what is realy meant is
>
> hostname foreach (@ domain);
Does it make any difference whether $_ is an alias or "the real thing" when
it comes to over-writing it?
ie, does the appended patch test exactly the same thing? The new code is:
# This checks that hostname does not overwrite $_
my $temp;
$_ = \$temp;
hostname;
# Numeric context on a ref returns the address, so == will compare addresses
ref ($_) && $_ == \$temp
? print "ok 2\n"
: print "not ok 2\n";
Nicholas Clark
--
Even better than the real thing: http://nms-cgi.sourceforge.net/
--- lib/Net/t/hostname.t.orig Sat Aug 24 21:13:52 2002
+++ lib/Net/t/hostname.t Wed Aug 28 21:48:51 2002
@@ -33,11 +33,12 @@ else {
}
# This checks that hostname does not overwrite $_
-my @domain = qw(foo.example.com bar.example.jp);
-my @copy = @domain;
+my $temp;
+$_ = \$temp;
-my @dummy = grep { hostname && $_ } @domain;
+hostname;
-($domain[0] && $domain[0] eq $copy[0])
+# Numeric context on a ref returns the address, so == will compare addresses
+ref ($_) && $_ == \$temp
This test was added because at one time hostname did corrunpt $_
If $_ is modified, then the value in $domain[0] will no longer
be equal to that in copy[0]
> And as all values in list are "true" then why is new code not
>
> grep { hostname && 1 } @domain;
> or
> grep { hostname } @ domain;
>
> Or perhaps what is realy meant is
>
> hostname foreach (@ domain);
Yes, but that does not work in earlier versions of perl.
This test is part of libnet, and has a life outside of the perl distribution
so supports older perl versions
Graham.
Graham.
foreach (@domain) {
hostname
}
then.
>
>This test is part of libnet, and has a life outside of the perl distribution
>so supports older perl versions
>
>Graham.
Sorry, I didn't realise.
Is there any easy way to find out from the perl distribution whether a file
is part of a CPAN module? Is there some file such as MANIFEST that lists
files which are part of packages on CPAN?
If not, I guess a file much like MANIFEST with 1 file perl line, but only
listing files also on CPAN. That way, one could grep it with filenames of
files one is submitting a patch for, and if the grep comes up with matching
lines, it would tell you who needed copying in.
ask and thou shalt receive... assuming that all modules in MANIFEST are
in the lib/ directory (Sorry, I *am* new here ;), this should do what
you want -- script also attached.
(Note, you'll need CPANPLUS to do it)
########################################################################
#!/usr/bin/perl -w
use strict;
use CPANPLUS::Backend;
open(my $FH, "$ARGV[0]") or die $!;
my $cb = new CPANPLUS::Backend;
while(<$FH>) {
next unless m|lib/(.+)?\.pm|i;
my $mod = join "::", split '/', $1;
my $modobj = $cb->module_tree->{$mod};
if( $modobj and $modobj->package !~ m|perl-[.\d]+\.tar\.gz|i) {
my $authobj = $cb->author_tree->{ $modobj->author };
printf "%-25s %-10s %-20s %-25s\n",
$mod, $authobj->cpanid,
$authobj->name, $authobj->email;
}
}
close $FH;
########################################################################
simply call it like this:
cpanmods.pl /path/to/manifest/to/examine
and it will output something that looks like this:
Net::SMTP GBARR Graham Barr gb...@pobox.com
Net::Time GBARR Graham Barr gb...@pobox.com
NEXT DCONWAY Damian Conway dam...@conway.org
for all modules in the manifest that are also listed in their own
packages on the CPAN
hope this is usefull
-Jos
Before perl is built, the pm files for XS modules live in ext/.
> #!/usr/bin/perl -w
> use strict;
> use CPANPLUS::Backend;
I'm completely unfamiliar with CPANPLUS, but here's my comments anyway :
> open(my $FH, "$ARGV[0]") or die $!;
>
> my $cb = new CPANPLUS::Backend;
> while(<$FH>) {
> next unless m|lib/(.+)?\.pm|i;
So this won't tell whether some .t, .pod or .PL files are found in CPAN.
Does CPANPLUS provide a way to list the contents of a CPAN distribution ?
> my $mod = join "::", split '/', $1;
>
> my $modobj = $cb->module_tree->{$mod};
> if( $modobj and $modobj->package !~ m|perl-[.\d]+\.tar\.gz|i) {
From what I know about the logic of the CPAN indexer, this previous
line is correct.
>Jos I. Boumans wrote:
>
>
>>ask and thou shalt receive... assuming that all modules in MANIFEST are
>>in the lib/ directory (Sorry, I *am* new here ;), this should do what
>>you want -- script also attached.
>>
>>
>
>Before perl is built, the pm files for XS modules live in ext/.
>
>
ext/Digest/MD5/MD5.pm
ext/Data/Dumper/Dumper.pm
i'm observing an extra layer in there compared to the lib/ entries... is
this consistent?
(if so, the script is easily adapted).
and out of curiosity, why is this?
>>open(my $FH, "$ARGV[0]") or die $!;
>>
>>my $cb = new CPANPLUS::Backend;
>>while(<$FH>) {
>> next unless m|lib/(.+)?\.pm|i;
>>
>>
>
>So this won't tell whether some .t, .pod or .PL files are found in CPAN.
>Does CPANPLUS provide a way to list the contents of a CPAN distribution ?
>
>
it could, but not without actually downloading and extracting the
package you're interested in, since there are no source files on the
CPAN (like 01mailrc.txt or 02package.details.txt) that give us this
information.
And even if you would be willing to download and extract, it would be
reversed logic:
ie, only after extracting we could index what is in the distribution.
regards,
jos
Not really -- for example you have in the MANIFEST :
ext/List/Util/lib/List/Util.pm List::Util
ext/List/Util/lib/Scalar/Util.pm Scalar::Util
so each XS module is built in its own subdirectory, controlled
by its makefile.
a quick look through the manifest gives me at least these different ways
of doing it:
### an extra 'subdirectory' called 'Dumper' being the only difference
compared to what
### /usr/lib/perl5/5.8.0 would have
### easy enough to parse
ext/Data/Dumper/Dumper.pm Data pretty printer, module
### have a subdirectory called 'lib' with same structure as
/usr/lib/perl5/5.8.0 would have
### comments show us 'perl name'
### fall back to comment if parse failes
ext/List/Util/lib/List/Util.pm List::Util
ext/List/Util/lib/Scalar/Util.pm Scalar::Util
### have a subdirectory called 'lib' with same structure as
/usr/lib/perl5/5.8.0 would have
### comments tell us nothing new
### tricky to parse
ext/Encode/lib/Encode/Alias.pm Encode extension
ext/Encode/lib/Encode/CJKConstants.pm Encode extension
ext/Encode/lib/Encode/CN/HZ.pm Encode extension
### have a script generating a .pm
### very tricky to parse correctly
ext/Errno/Errno_pm.PL Errno perl module create script
my questions:
* is there any reason, other than historical that these different
formats are around?
* is there a clear policy on how modules in the ext/ directories SHOULD
be added?
* is there a way to change the format so it is clearer from either the
directory structure, or the comment to what distribution these files
belong if they are on CPAN? (this would of course trivialise the
question in the subject, but might be worth considering)
regards,
jos
For what it's worth, I've been gradually building a utility to ease the
integration of updated modules. The current datafile for that is as
below (I'm gradually adding new modules as I need to discover the
information for them); the situation seems quite chaotic at the moment,
and I'd like to see it improved.
I plan eventually to include the utility, probably under the Porting
directory, since it could make it easier for dual-life module authors
to test updates against the perl distribution, and generally help to
make useful information more widely available.
Hugo
--- modules.txt
# key:
# map <path> <file1>, [<file2>, ...]
# means: map file1 etc from the distribution to the path <path>
# if <file> is a directory without a trailing slash, its path components
# are appended to the <map> path.
#
Unicode::Collate {
fetch http://homepage1.nifty.com/nomenclator/perl
ignore MANIFEST, Makefile.PL
map lib/Unicode Collate.pm
map lib/Unicode/Collate Changes README keys.txt t
}
podlators {
fetch ftp://ftp.eyrie.org/pub/software/modules
ignore ChangeLog MANIFEST Makefile.PL NOTES README THANKS TODO VERSION
map lib lib/
map pod scripts/
map lib/Pod/t t/
}
Math::BigInt {
fetch http://bloodgate.com/perl/packages
ignore BENCHMARK BUGS CHANGES CREDITS GOALS HISTORY INSTALL LICENSE MANIFEST
ignore Makefile.PL NEW README TODO examples/
map lib lib/
map t/lib/Math t/Math/
map lib/Math/BigInt/t t/
}
Math::BigRat {
fetch http://bloodgate.com/perl/packages
ignore BUGS CHANGES INSTALL LICENSE MANIFEST Makefile.PL NEW README TODO
map lib lib/
map t/lib/Math t/Math/
map lib/Math/BigRat/t t/
}
bignum {
fetch http://bloodgate.com/perl/packages
ignore BUGS CHANGES INSTALL LICENSE MANIFEST Makefile.PL README TODO
map lib lib/
map lib/bignum/t t/
}
Time::HiRes {
fetch ~CPAN/authors/id/J/JH/JHI
ignore MANIFEST README TODO
map ext/Time/HiRes Changes HiRes.xs Makefile.PL lib/Time/HiRes.pm t/
map ext/Time/HiRes/hints hints/
}
Test::Simple {
fetch http://www.pobox.com/~schwern/src
ignore MANIFEST Makefile.PL TODO
map lib/Test/Simple Changes README
map lib lib/
map t/lib t/lib/
map lib/Test/Simple/t t/
}
ExtUtils::MakeMaker {
fetch http://www.pobox.com/~schwern/src
ignore MANIFEST Makefile.PL NOTES README TODO
# Test::Simple etc
ignore t/lib/Test/
map t/lib t/lib/
map lib/ExtUtils Changes bin/instmodsh lib/ExtUtils/ t
}
Encode {
fetch http://www.dan.co.jp/~dankogai
ignore MANIFEST
map ext/Encode AUTHORS Changes Encode.pm Encode.xs Makefile.PL README
map ext/Encode encengine.c encoding.pm Byte CN EBCDIC Encode JP KR Symbol
map ext/Encode TW Unicode bin lib t ucm
}
Test {
fetch http://www.unm.edu/~lachler
ignore ChangeLog MANIFEST MANIFEST.SKIP Makefile.PL README TODO
map lib lib/
map lib/Test/t t/
}
ExtUtils::Constant {
fetch ~CPAN/authors/id/N/NW/NWCLARK
ignore Changes MANIFEST Makefile.PL README
map lib/ExtUtils Constant.pm t
}
CPAN {
fetch ~CPAN/authors/id/A/AN/ANDK
ignore ChangeLog Changes.old MANIFEST Makefile.PL README Todo
ignore lib/Bundle/
map lib lib/
map lib/CPAN/t t/
}