On 7/13/06, Matthew wrote:
> Apologies for this being off-topic, but this is the best "perl resource"
> I have.



> my $test = [2, 4, 8];
> print $test;
> >Array(0x3038303)

>
> Oh? That's an array format. OK. Try this:
>
> my @test = (2, 4, 8);
> print @test;
> >248

>
> ??? Confused.
>
> If anyone could please explain what I missed on the differences between
> ( ) array's and [ ] array's, I'd appreciate it.


() is a LIST of values, perfect for plopping into an array:

@a = (qw/one two three/, 22/7, pi())

the way you pick out elements of an array are with the [brackets]:

print $a[two], $a[pi()].

so the perl wonks figured it would be cool to have insta-arrays at
your fingertips by using the brackets without an array name:

$x = [$val,@array,&function];
print $x->[1],$x->[-1];

usually this type of thing is more usefully applied to hashes:

%x = (one=>1, nine=>9, fifty=>50);
$x = {one=>1, two=>2, structure=>{one_one=>1.1,nine_two=>9.2},more=>'yup'}
print $x->{structure}->{one_one};
or, more succinctly...
print $x->{structure}{one_one};

see man perlref or man perlreftut for the full deal.

--
will trillich
"The great enemy of clear language is insincerity." -- Eric Arthur
Blair (George Orwell)