Is Perl *that* good?
Carl Banks
imbosol at aerojockey.com
Wed Apr 28 18:59:45 EDT 2004
claird at lairds.com (Cameron Laird) wrote in message news:<108v74768o9sb9f at corp.supernews.com>...
> In article <XwEjc.31513$Vp5.16074 at fe2.columbus.rr.com>,
> Carl Banks <imbosol at aerojockey.invalid> wrote:
> .
> .
> .
> >If you do stuff recursively (as I often do) or break up code into
> >smaller functions (as I often do) so that the functions with these
> >regexps get called numerous times, it can help performance to move the
> >compile step out of the functions.
> >
> >The point is, the existence re.compile encourages people to make
> >regexp objects global so they only need to be compiled once, when the
> >module is loaded. Because of this, and especially because regexps are
> >prone to being used in recursive functions and such, it's dangerous to
> >allow them to have state.
> .
> .
> .
> I wrote the subject line for this subthread. Here's
> my provisional conclusion: my past attempts to track
> down claims of the "Perl is tops for string-handling"
> sort generally reinforced the proposition that the
> speaker simply meant, "Perl privileges REs" (and that
> the speaker had no familiarity with Python, let alone
> Icon or Prolog). Now I see there's a likelihood of
> definite attraction to the hidden-variable, dangerous
> implicitness goop so characteristic of Perl. That's
> good to understand. Thanks, Carl; good analysis.
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.
--
CARL BANKS
More information about the Python-list
mailing list