--- Bryan R Harris <[EMAIL PROTECTED]> wrote:
>
> Wow, you guys are amazing... This most recent seems to work, so I'm set
> (though I still don't quite understand it).
>
> A few quick questions:
>
> 1. What does this do?: $somevar = [ @somearray, $somescalar ];
The construct "@somearray, $somescalar" creates a list with $somescalar as the last
item of the
list. The square brackets around the list create a reference to an anonymous array
(whose
contents are the list) and assigns the reference to $somevar. Example:
my @somearray = qw/ Red Gold Green /;
my $somescalar = 'Ovid';
my $somevar = [ @somearray, $somescalar ];
Now, to get to the third item in the anonymous array, you must dereference it with the
arrow
operator (remembering that arrays start with zero):
print $somevar->[2]; # prints "Green"
> 2. and this?: $somevar = $someothervar->[$athirdvar];
This should be explained above.
> 3. and this?: $somevar = \@somearray;
Putting a backslash in front a a sigil creates a returns a reference to it, which is
assigned to
the scalar. This is identical to using square brackets to create an array reference:
$somevar = [ @somearray ];
Cheers,
Curtis "Ovid" Poe
=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]