Is Perl *that* good?
Carl Banks
imbosol at aerojockey.com
Wed Apr 28 21:54:13 EDT 2004
imbosol at aerojockey.com (Carl Banks) wrote in message news:<60dfb6f6.0404281459.21675af4 at posting.google.com>...
> In file x.pl:
>
> sub muck() {
> $_ = "sucker\n";
> }
>
> while(<>) {
> if (/^abc/) {
> muck();
> print $_;
> }
> }
>
> Command line:
>
> echo abcdefg | perl x.pl
>
> Output:
>
> sucker
>
>
> I had actually thought it restored $_.
> It never ceases to amaze me how bad Perl is.
Wait a minute, Perl does restore the regexp implicits.
In file x.pl:
sub muck() {
$_ = sucker;
/sucker/;
}
while(<>) {
if (/^abc/) {
muck();
print $&;
print "\n";
}
}
Command line:
echo abcdefg | perl x.pl
Output:
abc
Perl has failed to amaze me at just how bad
it is this one time. :)
--
CARL BANKS
More information about the Python-list
mailing list