in reply to Re: system() and backticks question
in thread system() and backticks question

As far as my understanding of arrays, scalars and hashes goes, $arr[0] is correct from a syntactical standpoint, but from a functional standpoint @arr[0] seems virtually indentical.

-Jerry
http://www.digilliance.net

Replies are listed 'Best First'.
Re (3): system() and backticks question
by VSarkiss (Monsignor) on Sep 05, 2001 at 22:21 UTC

    I wouldn't make such statements when brother merlyn is around. ;-)

    The difference is a big one. An array slice (which is what @arr[0] is) provides a list context, whereas an array element provides a scalar context. For a graphic illustration, try this code:

    my @d = qw(this is a plain array); my @a; $a[0] = @d; print "The scalar got '$a[0]'\n"; @a[0] = @d; print "But the array slice got '$a[0]'\n";
    Many things in Perl will behave differently in scalar versus list context. If you continue to use @a[0] when you mean $a[0], you will have a surprise one day.

    OTOH, it's your code....