Lawrence Statton wrote:
From [EMAIL PROTECTED]  Wed Aug  8 15:44:30 2007
Return-Path: <[EMAIL PROTECTED]>
X-Original-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: from localhost (localhost [127.0.0.1])
        by hummer.cluon.com (Postfix) with ESMTP id 25F66339A0
        for <[EMAIL PROTECTED]>; Wed,  8 Aug 2007 15:44:30 -0500 (CDT)

[ SNIP ]

To: Perl List <beginners@perl.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Message-ID: <[EMAIL PROTECTED]>
Status: O
X-UID: 551443
X-Keywords:


*WHY* OH MY $DEITY *WHY* did you quote all the headers of the original email?



Trying to understand from perldoc perldata the diff
between these 3 CLIs and why the 2nd CLI has no
elements?


That the anonymous array consists of values identical to their indices is 
probably not enlightening you.

The OP's question did not involve anonymous arrays, nor do your examples.


Consider the following:


perl -e 'use Data::Dumper; @c = (qw / one two / )[0]; print Dumper ([EMAIL 
PROTECTED]) '
$VAR1 = [
          'one'
        ];

perl -e 'use Data::Dumper; @c = (qw / one two / )[1]; print Dumper ([EMAIL 
PROTECTED]) '
$VAR1 = [
          'two'
        ];


# there is no 2nd element in the source array -- only [0] and [1] are defined.

There is no "source array". The OP and your example are trying to access the *3rd* element of a *LIST* which only has two elements.

perl -e 'use Data::Dumper; @c = (qw / one two / )[2]; print Dumper ([EMAIL 
PROTECTED]) '
$VAR1 = [];
#
# a slice of the first two elements in the source array

Again, no array, *LIST*.

#
perl -e 'use Data::Dumper; @c = (qw / one two / )[0,1]; print Dumper ([EMAIL 
PROTECTED]) '
$VAR1 = [
          'one',
          'two'
        ];


Array element: $a[ 0 ]
Array slice:   @a[ 0, 1, 2 ]


List element: ( 0 )[ 0 ]
List slice:   ( 0, 1, 2 )[ 0, 1, 2 ]


Anonymous array element: [ 0 ]->[ 0 ]
Anonymous array slice:   @{[ 0, 1, 2 ]}[ 0, 1, 2 ]




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to