Re: define an array in perl



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);

.



Relevant Pages

  • Re: Learning Perl
    ... it should be an array, ... Then they'd be completely inaccessible to beginners. ... that should be my $var. ... so why is it redundant to point out that Perl is different from C here? ...
    (comp.lang.perl.misc)
  • Re: perl vs Unix grep
    ... variable indexCount on array and reintialized evry time. ... Perl is langauge to make things work at any cost. ... > grep but the shell scripts that use ... As far as I can tell from reading and research ...
    (comp.lang.perl)
  • Re: Learning Perl
    ... EB> Perl with very good results: ... it should be an array, ... used as the delimiter besides ... string1 string2! ...
    (comp.lang.perl.misc)
  • FAQ 4.42 How can I tell whether a certain element is contained in a list or array?
    ... comes with the standard Perl distribution. ... How can I tell whether a certain element is contained in a list or array? ... used a hash, not a list or array, to store your data. ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ...
    (comp.lang.perl.misc)
  • Re: delimited data into nested array
    ... > file) into Perl as a two dimensional nested array. ... not declared your variables and enabled strictures. ... Here you are using symbolic references, ...
    (comp.lang.perl.misc)