perl bug with references

Discussion in 'Perl Misc' started by dt, Feb 28, 2007.

  1. dt

    dt Guest

    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"
     
    dt, Feb 28, 2007
    #1
    1. Advertising

  2. dt

    Ben Morrow Guest

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


    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.
    Kurt Vonnegut
     
    Ben Morrow, Feb 28, 2007
    #2
    1. Advertising

  3. dt

    Thomas J. Guest

    On 28 Feb., 03:13, "dt" <> 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
     
    Thomas J., Feb 28, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Leigh
    Replies:
    8
    Views:
    464
    Karl Heinz Buchegger
    Nov 17, 2003
  2. Replies:
    3
    Views:
    474
    Victor Bazarov
    Nov 10, 2004
  3. DanielEKFA
    Replies:
    8
    Views:
    631
    DanielEKFA
    May 16, 2005
  4. Replies:
    8
    Views:
    745
    Bruno Desthuilliers
    Dec 12, 2006
  5. Lars Willich
    Replies:
    13
    Views:
    887
    Ian Shef
    Oct 23, 2007
Loading...

Share This Page