develooper Front page | perl.perl5.porters | Postings from August 2013

[perl #54728] PathTools-3.27 triggers a bug in Perl

Thread Previous | Thread Next
Victor Efimov via RT
August 6, 2013 13:45
[perl #54728] PathTools-3.27 triggers a bug in Perl
Message ID:
On Tue Aug 06 06:32:12 2013, davem wrote:

> Probably not, but in the same way that the user probably doesn't want
> sub f { $_ = 1 }
> to modify $_[0], but it will if called as
> f($_);

if $_ is localized, then code

sub f { local $_ = 1; print $_[0] }
print $_;

prints 22, so $_[0] is not modified.

is subroutine intention is to modify global $_, it should be documented,
and modified $_ and even $_[0] is expected behaviour.

subroutine that does not localize $_ and does not document this,
subroutine is buggy imho.

> I think any code that passes raw global 'magic' vars as args to subs (e.g.
> without stringifying them a la "$1"), is asking for trouble:

Ok, get it. So caller responsible for this. Then it's probably thing to
report as feature request for perlcritic.

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About