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.
Re: Find the bug! (localize) (Score:1)
As a lesson, you should always localize $_ and the other stuff when assigning to it...
perl -le "sub _import{$_=shift};for('foo'){_import($class,$arg)}"Re: (Score:1)
Re: (Score:1)
Sorry, not gonna. Perl has
$_for a reason.Re: (Score:0)
Re: (Score:2)
At this point, I can't say we'd be that much worse off, except for the horrible programming language they would force us to standardize on [wikipedia.org].
Modifying @_? (Score:1)
If
# do stuffmodifies$_thenforeachaliasing will try to modify the relevant entry in@_.That's unlikely to be desired, and I think will cause a crash if the caller passed a constant in.
Re: Modifying @_? (Score:1)
Since the code is using
whilerather thanforeachand more importantly shift rather than aliasing, this isn't going to be the bug in this code. When weshift, we copy, so changes (in this case) to$_won't change@_.Having said that, I'd much prefer the original code to say:
But then changing $arg would hit the problems you're thinking of.
Re: (Score:1)
for my $arg (my @copy = @_) { ... }Re: (Score:1)
Hmmmm, clearly I can't read! Ooops.