Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my data file contains lots of lines similar to the one at the top , what I need is to get the last two words in each line and print them , in the case above , my output should bemy %lineFileContains; my @r = (); open my $fh, "ZaaFile" or die "open failed: $!"; my $line; while ($line = <$fh>) { chomp (@r = split/\s+/); push @{$lineFileContains{$r[3]}}, [@r[4..$#r]]; } close $fh; foreach (reverse sort keys %lineFileContains) { print "$_"; foreach (@{$lineFileContains{$_}}) { print "\t$_->[3]\t$_->[4]\n"; } } data ---- A 234453234324 Hlell Sam Two
Not sure if it is my hash or my print statment. thanksSam Two
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: values of hash table
by esskar (Deacon) on Mar 04, 2004 at 05:57 UTC | |
|
Re: values of hash table
by Anonymous Monk on Mar 04, 2004 at 06:16 UTC | |
|
Re: values of hash table
by TomDLux (Vicar) on Mar 04, 2004 at 18:25 UTC |