Re: define an array in perl
- From: ivakras1@xxxxxxxxx
- Date: Tue, 31 Jul 2007 11:03:45 -0000
On 31 , 14:43, jeniffer <zenith.of.perfect...@xxxxxxxxx> wrote:
Hi
I am a newbie in perl. 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...
sorry for the stupid question,,,please help me out ,,,,
arrays starts its name from @. you cant define an array with the name
$list_name, it looks like a string, member of array, but not the
array. You may want to split $list_name into array. So use split().
Example: my @arr=split('-',$list_name). It splits the string
$list_name into an array with '-' as a delimiter.
my $str="abc-def-123-456";
my @array=split('-',$str);
.
- References:
- define an array in perl
- From: jeniffer
- define an array in perl
- Prev by Date: Re: define an array in perl
- Next by Date: Re: Perl threads
- Previous by thread: Re: define an array in perl
- Next by thread: Variable declaration - C vs script style
- Index(es):
Relevant Pages
|
|