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

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

Thread Previous | Thread Next
From:
Victor Efimov via RT
Date:
August 6, 2013 13:45
Subject:
[perl #54728] PathTools-3.27 triggers a bug in Perl
Message ID:
rt-3.6.HEAD-2552-1375796696-9.54728-15-0@perl.org
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] }
$_=2;
f($_);
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
https://rt.perl.org:443/rt3/Ticket/Display.html?id=54728

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About