For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > February 2007 > perl bug with references









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author perl bug with references
dt

2007-02-27, 10:03 pm

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"

A. Sinan Unur

2007-02-27, 10:03 pm

"dt" <ppc@cheapbooks.com> wrote in news:1172628837.171444.221380
@p10g2000cwp.googlegroups.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"


Don't use regexes when the humble eq operator would suffice.

Please post a short but complete script that demonstrates the behavior.

Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmis...guidelines.html

Ben Morrow

2007-02-28, 4:02 am


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.

2007-02-28, 8:04 am

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com