NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Regexps and T-SQL (Score:1)
Regexps are usually very compact and opaque. Your comment about whitespace is spot on, so
Re: $_ (Score:1)
I think the exact opposite.
$_has a meaning in Perl: “the current ‘thing’ being operated on”. That's a well-defined convention, and it has the advantage of being the same in every program.In other languages when people want a temporary variable they often use
iornors, but they aren't more readable than$_.If you've got an
@serverarray of objects, and perhaps a$server_numvariable too, and you want to iterate over each server, you could call the iterator variable$server, but then you have several variables with very similar names. Far better to use the form offoreachthat doesn't explicitly name an iterator variable to avoid having to synthesize an artificial name, and use the standard name that Perl already provides.Reply to This
Parent
Re: $_ (Score:1)
If the code block is very brief, like in
then I agree that it isn't necessary to alias it to a new name. But if the code block is longer than a few lines, it's indeed very useful to have an actual name connected to the entity you're dealing with.
Consider the followi