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:
James E Keenan via RT
Date:
August 4, 2013 13:57
Subject:
[perl #54728] PathTools-3.27 triggers a bug in Perl
Message ID:
rt-3.6.HEAD-2552-1375624618-513.54728-15-0@perl.org
On Sun Aug 04 06:14:16 2013, chorny wrote:
> This ticket can be viewed as two tickets:
> 1. Bug in PathTools (fixed)
> 2. This problem:
> #!perl
> 
> "2" =~ m/(.*)/;
> print test1("1", $1), "\n";
> 
> sub test1 {
>   'aa' =~ m/(.)/;
>   return $_[0].'/'.$_[1];
> }
> prints "1/a" on perl 5.18.0.
> 
> Can it be considered a bug?
> 
> 

No, I don't think so.

With this line:

>   'aa' =~ m/(.)/;

... you have made a new assignment to global variable $1.  Hence, you
have changed the value to which $_[1] is aliased.  From
'pod/perlsub.pod' (blead):

#####
Any arguments passed in show up in the array @_.
Therefore, if you called a function with two
arguments, those would be stored in $_[0] and
$_[1]. The array @_ is a local array, but its
elements are aliases for the actual scalar
parameters. In particular, if an element $_[0] is
updated, the corresponding argument is updated (or
an error occurs if it is not updatable).
#####

I'll take this ticket for the purpose of closing it within 7 days unless
someone thinks we still have a bug in Perl.

Thank you very much.
Jim Keenan

---
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