For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > November 2006 > @$var....what does this mean









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author @$var....what does this mean
Gowthaman Ramasamy

2006-11-15, 6:55 pm


Hi List,
I was reverse enginering some perl-cgi codes.
I found the following expression.....can any one tell me what does this =
mean.

when do we use @$somevar

is it for spliting...if then at what suituiation this works....


following the script
my @results =3D &do_sql_2D($dbproc, $query); =3D=3D> quries a mysql =
database
foreach my $result (@results)=20
{
my ($status_id, $status_descr) =3D @$result; =
##############need to understand this line....
print "$status_id\n";

}

many thanks in advance,
gowtham
lawrence@cluon.com

2006-11-15, 6:55 pm

>
> following the script
> my @results = &do_sql_2D($dbproc, $query); ==> quries a mysql database
> foreach my $result (@results)
> {
> my ($status_id, $status_descr) = @$result; ##############need to understand this line....
> print "$status_id\n";
>
> }
>


In your inner loop $result is an array reference. It is a scalar
variable that refers to an array (apparently, in this case, of two
elements.)

perldoc perlreftut

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
sort them into the correct order.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com