QA

 <  Day Day Up  >  

Q&A

Q1:

When I print a list of lists with print "@LOL" , it prints ARRAY(0x101210),ARRAY(0x101400) , and so on. Why?

A1:

With a normal array, print "@array" would print the elements of the array with a space between them. The print "@LOL" is doing just that, printing the array elements in @LOL . To print the components of each of the arrays in @LOL , you must use the technique described in the "Example: List of Lists" section earlier in this hour .

Q2:

I tried to take a reference to a list by using $ref=\( $a, $b, $c) and ended up with $ref containing a reference to a scalar value instead of a list. Why?

A2:

In Perl, \($a, $b, $c) is actually shorthand for (\$a, \$b, \$c) ! What you wound up with is a reference to the last element in the parentheses, $c . To take a reference to an anonymous array, you should have used $ref=[$a, $b, $c]; instead .

 <  Day Day Up  >  


SAMS Teach Yourself Perl in 24 Hours
Sams Teach Yourself Perl in 24 Hours (3rd Edition)
ISBN: 0672327937
EAN: 2147483647
Year: 2005
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net