in reply to insert into a hash
From your description, I wrote this:
my %hash; my @labels = qw(Date,Login,Searchload,Searchsave,Searchdetails,Searchd +elete); while ( my $line = <FILE> ) { chomp $line; my @fields = split /,/, $line; foreach my $label ( @labels ) { push @{ $hash{ $label } }, shift @fields; } }
You might want to consider using Text::CSV_XS. And, as always, Use strict and warnings.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: insert into a hash
by AnomalousMonk (Archbishop) on Mar 26, 2009 at 22:42 UTC |