qingdaoghawk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Monks! I am trying to creat a series of arrays whose names are the values of a series of scalars. Here is the code:
while(<FGLCS>){ chomp; ($scfd_name_frgt,$stt_pst_frgt,$stp_pst_frgt,$lgh_frgt)=split /\t/,$_; $scfd_name_frgt=reverse $scfd_name_frgt; unless($scfd_name_frgt eq $scfd_name_frgt_tmp){ $scfd_name_frgt_tmp=$scfd_name_frgt; @{$scfd_name_frgt}=($stt_pst_frgt,$stp_pst_frgt,$lgh_frgt); $frgtlocs{$scfd_name_frgt}=\@{$scfd_name_frgt}; } else{ push @{$frgtlocs{$scfd_name_frgt}},($stt_pst_frgt,$stp_pst_frgt,$lgh_f +rgt); } }
I wish to creat the arrays whose names are the values of the scalars "$scfd_name_frgt". But under "use strict", @{$scfd_name_frgt} is defined as dereference of reference of $scfd_name_frgt. How can I name arrays via scalars values under "use strict" ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to name arrays via scalars.
by AnomalousMonk (Archbishop) on May 03, 2014 at 09:29 UTC | |
by qingdaoghawk (Initiate) on May 03, 2014 at 11:49 UTC | |
|
Re: How to name arrays via scalars.
by hdb (Monsignor) on May 03, 2014 at 10:04 UTC | |
by qingdaoghawk (Initiate) on May 03, 2014 at 12:03 UTC | |
|
Re: How to name arrays via scalars.
by Laurent_R (Canon) on May 03, 2014 at 09:58 UTC | |
by qingdaoghawk (Initiate) on May 03, 2014 at 11:59 UTC |