Re: define an array in perl
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Tue, 31 Jul 2007 12:59:34 +0200
jeniffer wrote:
I have an array block_list :
push ( @block_list ,$word); # this word is read from a file.
$list_name = $block_list[$#block_list]; # i extract the last element
ie $word in this case
now i want to define an array with the name $list_name
like ,
my @"$list_name";
But this is giving me errors...
It can be done, but is not recommended. Consider this solution instead:
my $word = 'Perl';
my %lists; # declare a HoA
push @{ $lists{$word} }, $word;
print @{ $lists{Perl} }, "\n"; # prints 'Perl'
You may want to read the FAQ entry
perldoc -q "variable name"
about why what you tried to do is not recommended.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- define an array in perl
- From: jeniffer
- define an array in perl
- Prev by Date: define an array in perl
- Next by Date: Re: define an array in perl
- Previous by thread: define an array in perl
- Next by thread: Re: define an array in perl
- Index(es):
Relevant Pages
|