in reply to dynamically named arrays
Rather than trying to create dynamically named arrays (which can be done but requires using things called symbolic references which are generally frowned upon unless there is a specific reason for their use) a hash of arrays seems like your best option here.
Some sample code to get you started. See perldata and perlreftut for further info.
#! perl -sw use strict; my %files; while(<DATA>) { chomp; my ($type, $ts) = m/(..)(.*)/; $files{$type} = [] if not exists $files{$type}; push @{$files{$type}}, $ts; } foreach my $type (keys %files) { print $type,$_,$/ for sort @{$files{$type}}; } __DATA__ vs010101.000 ud010101.000 ve020202.000 eq131302.000 eq010101.000 vs031102.000 us020101.000 ve051001.000
Gives output
c:\test>206767 eq010101.000 eq131302.000 us020101.000 ud010101.000 vs010101.000 vs031102.000 ve020202.000 ve051001.000 c:\test>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: dynamically named arrays
by Anonymous Monk on Oct 21, 2002 at 05:18 UTC | |
by Sinister (Friar) on Oct 21, 2002 at 09:06 UTC | |
by thor (Priest) on Oct 21, 2002 at 15:31 UTC | |
by iburrell (Chaplain) on Oct 21, 2002 at 19:05 UTC | |
by demerphq (Chancellor) on Oct 21, 2002 at 11:02 UTC |