develooper Front page | perl.perl5.porters | Postings from June 2010

[perl #75812] kill $1 broken in 5.12.1

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
June 17, 2010 08:35
Subject:
[perl #75812] kill $1 broken in 5.12.1
Message ID:
rt-3.6.HEAD-4976-1276766198-1817.75812-15-0@perl.org
On Wed Jun 16 13:08:00 2010, toddr@cpanel.net wrote:
> We've discovered that this snippet will break in perl 5.12
> 
> my $pid = "12345  ";
> if($pid =~ m/(\d+)/) {
> 	kill 9, $1;
> }
> 
> it dies with this message:
> Can't kill a non-numeric process ID at test.pl line 7.
> 
> 
> The reason appears to be a result of this commit.
>
http://perl5.git.perl.org/perl.git/commitdiff/e2c0f81f627951896aca833460887e6e8f20aba6?hp=32878f30ba1216461c8932946f0868cda9920d62
> 
> Using Devel::Peek, I'm guessing the problem is that IV doesn't get set
> on a $1 variable?
> 
> For some reason I can't understand,  I can make this problem go away
> if I do 'use 5.12.1' at the beginning of my code. $1+0 also forces
> kill to work.

$1 is magic, so until SvGETMAGIC() is called it has no flags.

Patch calls SvGETMAGIC() before checking the flags, and uses the no
magic variant of SvIV() avoid to double magic.

looks_like_number() can also call SvGETMAGIC() via SvPV_const(), but
that's a different problem.

Tony

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