perl bug with references

D

dt

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

Ben Morrow

Quoth "dt said:
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
 
T

Thomas J.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top