in reply to Re^5: referencing slices - love that DWIM
in thread referencing slices - love that DWIM

However, from the point of view of a perl programmer they are as near as damnit the same thing.
  • Comment on Re^6: referencing slices - love that DWIM

Replies are listed 'Best First'.
Re^7: referencing slices - love that DWIM
by Fletch (Bishop) on May 19, 2008 at 12:13 UTC

    Except for in the edge cases, which is where thinking they are the same thing gets you into trouble:

    • the \( @array ) vs \@array behavior in question here
    • push|splice|etc require an actual ARRAY as their first argument, not a LIST
    • a LIST and an ARRAY will behave differently in scalar context (contrast scalar qw( a b c ) with scalar @{[ qw( a b c ) ]})

    Those are three that readily come to my pre-morning-caffeine brane, but there's certainly others. Yes in most cases they'll behave the same, but you need to understand that it is a simplification and know where the idea breaks down. Otherwise you'll be unpleasantly surprised after you have to go chasing down squirrelly context induced wonkyness.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.