Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   perl bug with references (http://www.velocityreviews.com/forums/t902042-perl-bug-with-references.html)

dt 02-28-2007 02:13 AM

perl bug with references
 
I found an odd behavior.

when I have a reference, let's say it is an array, it seems to pad the
value differently in perl 5.6 vs 5.8:

this worked in perl 5.8 but not perl 5.6:

$ref =~ /^ARRAY/;

for 5.6, I had to change to =~ /^\s*ARRAY/;

could not find anything mentioning this behavior anywhere. I doubt it
is a "feature"


Ben Morrow 02-28-2007 04:29 AM

Re: perl bug with references
 

Quoth "dt" <ppc@cheapbooks.com>:
> I found an odd behavior.
>
> when I have a reference, let's say it is an array, it seems to pad the
> value differently in perl 5.6 vs 5.8:
>
> this worked in perl 5.8 but not perl 5.6:
>
> $ref =~ /^ARRAY/;
>
> for 5.6, I had to change to =~ /^\s*ARRAY/;
>
> could not find anything mentioning this behavior anywhere. I doubt it
> is a "feature"


Works for me:

~% perl -v

This is perl, v5.8.8 built for i686-linux
....

~% perl -le'print [] =~ /^ARRAY/ ? "match" : "no match"'
match
~%

You shouldn't be doing this anyway. Use Scalar::Util::reftype.

Ben

--
All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk Kurt Vonnegut

Thomas J. 02-28-2007 11:19 AM

Re: perl bug with references
 
On 28 Feb., 03:13, "dt" <p...@cheapbooks.com> wrote:
> I found an odd behavior.
>
> when I have a reference, let's say it is an array, it seems to pad the
> value differently in perl 5.6 vs 5.8:
>
> this worked in perl 5.8 but not perl 5.6:
>
> $ref =~ /^ARRAY/;
>
> for 5.6, I had to change to =~ /^\s*ARRAY/;
>


I have same results with perl 5.6.

perldoc -f ref

hope that helps,

Thomas



All times are GMT. The time now is 07:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.