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

A list is an ephermeral thing; a transient set of values on the call stack

Ok ... so if, as the docs say, \(@foo) returns a list, then precisely what does [\(@foo)] return ? Is it (something like) "a reference to an array comprising the list returned by \(@foo)" ? (What's the correct terminology ?)

Cheers,
Rob

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

    That's a single scalar value, which is the anonymous array reference containing a list of references to the individual elements of the array @foo. Maybe this will clear it up.

    use Data::Dumper qw( Dumper ); my @foo = qw( a b c ); my $x = [ \( @foo ) ]; print Dumper( $x ), "\n"; ${ $x->[1] } = 'z'; print join( "\n", @foo ), "\n"; print Dumper( $x ), "\n";

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