Re: perl bug with references




Quoth "dt" <ppc@xxxxxxxxxxxxxx>:
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@xxxxxxxxxxxx Kurt Vonnegut
.



Relevant Pages

  • Re: Complex Objects in Perl
    ... > Objects in Perl are implemented as a reference to an ... > anonymous hash. ... > array or a hash or it may be another object (reference to ... > installation of perl: ...
    (comp.lang.perl)
  • Re: Complex Objects in Perl
    ... > sub-object is made up of a number of different objects and an array of an ... Objects in Perl are implemented as a reference to an anonymous hash. ...
    (comp.lang.perl)
  • Re: Learning Perl
    ... it should be an array, ... Then they'd be completely inaccessible to beginners. ... that should be my $var. ... so why is it redundant to point out that Perl is different from C here? ...
    (comp.lang.perl.misc)
  • Re: Complex Objects in Perl
    ... >> Objects in Perl are implemented as a reference to an anonymous hash. ... >> enumerate over array and hash members as you would enumerate over any ...
    (comp.lang.perl)
  • Re: Which is faster - hash or array lookup
    ... I am suite sure that perl is not The Right Tool ... Each player has 5 pieces, and additionally there is a common ... whereas traversing an array looking for $n is slow). ...
    (comp.lang.perl.misc)