Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The hash is something like TEST1 (key) - all *.me's as values. I am looking at passing *.me as an argument and it should return the corresponding key. HELP!!??? Thanks#!/usr/bin/perl %Test_hash=(); open(F, "xfile.test"); while ($line=<F>){ if ($line=~ /FIRST/) { ($Test_num,$Test)=(split(/\s+/,$line))[0,2]; push (@Tests,$Test); @all_me=(); } if ($line=~ /SUBSET/ ) { $me=(split(/\s+/,$line))[2]; push(@all_me,$me); $Test_hash{$Test} = [@all_me]; } } use Data::Dumper; print Dumper([\%Test_hash]); __DATA__ <xfile.test> FIRST ONE TEST1 SUBSET a.me SUBSET b.me SUBSET c.me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Return value given a key
by Perl Mouse (Chaplain) on Nov 22, 2005 at 11:20 UTC | |
by monarch (Priest) on Nov 22, 2005 at 13:01 UTC |