Today's Perl puzzler: What I wanted to print the module name and the distro name without the version number, as in
but the following code didn't print anything at all. What was my bug?
$distro =~ s[.+/][];
$distro =~ s[-\d+\.\d+\.tar\.gz];
print $module, " ", $distro, "\n";
}
__END__
Test::AtRuntime 0.02 M/MS/MSCHWERN/Test-AtRuntime-0.02.tar.gz
Test::Builder 0.17 M/MS/MSCHWERN/Test-Simple-0.47.tar.gz
Test::Builder::DatabaseRow 1.01 P/PR/PROFERO/Test-DatabaseRow-1.01.tar.gz
Test::Builder::Tester 0.09 M/MA/MARKF/Test-Builder-Tester-0.09.tar.gz
Hey, that's not a complete statement!$distro =~ s[-\d+\.\d+\.tar\.gz];
Re:Hmm
vsergu on 2003-12-01T17:53:03
Ah, but that's because you didn't finish it. You only included the opening semicolon delimiter for the replacement. The complete statement is
which is the same as$distro =~ s[-\d+\.\d+\.tar\.gz];
print $module, " ", $distro, "\n";$distro =~ s/-\d+\.\d+\.tar\.gz/\n print $module, " ", $distro, "\n"/
#!/usr/bin/perl
while (<DATA>) {
chomp;
my( $module, undef, $distro ) = split;
$distro =~ s[.+/][];
$distro =~ s[-\d+\.\d+\.tar\.gz][];
print $module, " ", $distro, "\n";
}
__END__
Test::AtRuntime 0.02 M/MS/MSCHWERN/Test-AtRuntime-0.02.tar.gz
Test::Builder 0.17 M/MS/MSCHWERN/Test-Simple-0.47.tar.gz
Test::Builder::DatabaseRow 1.01 P/PR/PROFERO/Test-DatabaseRow-1.01.tar.gz
Test::Builder::Tester