Bryan Harris wrote:
Hi,
I'm trying to figure out how to print the following array. How do I
print this type of thing? Please let me know if I'm posting to the
wrong list.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Long;
my $name;
GetOptions('[EMAIL PROTECTED],}' => \$name);
print $name;
When I run the program I get the following results.
./getopts.pl --name bryan stephen robert
ARRAY(0x81308f4)%
I've tried several different ways of printing it, but with no luck so
far. Sometimes I get the following type of message, when I use
different variables like \$name[1], or other variations.
Global symbol "@name" requires explicit package name at ./getopts.pl
line 10.
Execution of ./getopts.pl aborted due to compilation errors.
You have to dereference the reference:
print @$name;
Or:
print @{ $name };
To access a member of the array, you use the arrow operator:
print "The first value is $name->[0]\n";
See `perldoc perlreftut` and `perldoc perlref` for more info.
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by doing them."
Aristotle
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/