On 1/16/2004 11:03 AM, Jack Chen wrote:

Hi,

I don't know how to work with this data structure:

my @array = ((a         =>   'appple'),
             (b         =>   'tree'),
             (c         =>   'chair'));

when I do:

print @array;

I get no output.

when I do:

use Data::Dumper;
print Dumper(@array);

I got the contents of it.

Despite all of the punctuation, it is nothing more than an array. The following is equivelant:

my @array = qw( a apple b tree c chair );

I find it more helpfull when using Data::Dumper to print a reference to
the variable I want to examine. I.e.

print Dumper([EMAIL PROTECTED]);

To me it makes the structure easier to interpret. I don't understand
though why you saw nothing for 'print @array', are you sure you ran the
code as above. I get:

print @array;
=> aappplebtreecchair

print "@array";
=> a appple b tree c chair

Regards,
Randy.





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




Reply via email to