Am Dienstag, 3. Mai 2005 23.42 schrieb [EMAIL PROTECTED]:
> John,
> I am a lotus user so my top-down reply is default ...sorry.

Don't know Lotus. No possibilities to change defaults there? ;-)

> I think all looks good, but I have to ask why are you initializing an array
> to hold values of a hash with keys?

Because you wrote in your question:

| I was thinking of using a hash of arrays b/c I want to look-up each array
| by a certain string and that string would the % string.| [...]

which, even after rereading it, says that you want 
a) to lookup something _by_ the % string, and that means the % string must be 
the hash key,
b) to lookup arrays, which means the hash values are multi valued

and 

|  Here is the data file:
| 
|  1     2005/01/20 15:39   17   2%  -il-o-b-----  sg F01000
|  2     2005/01/20 15:53   14   1%  -il-o-b-----  sg F01001
|  3     2005/01/18 09:53    2   0%  -il-o-b-----  sg F01002
|  4     2005/02/04 16:41  196 100%  -il-o-b----f  sg F01003
|  5     2005/02/05 21:13  305 100%  -il-o-b----f  sg F01004

the % string is not unique over data file, whereas the F... string looks like 
being unique.

and

because it seemed to make sense for me looking up the data by the pct value.


> My whole purpose was to populate a hash like so:
> 
> my %hash = {
> 
>       F01000 => '0%',
>       F01001 => '10%',
>       F01002 => '100%',
> };
> 
> If one cannot and should not push a hash, then what is the ideal way to
> populate a hash..... like so?
>             for ( <FH>) {
>              for my $d (keys %HoA) {
>                 print "$d: @{$HoA{$d} }\n";
>              }
>             }
> 
> OR
>               my %HoA = ();
>                   for (<FH> ) {
>                   $HoA{$i++} = (split)[-1]
>                 }

Since only the second snippet populates a hash, I'd say the second is better.



joe

[snipped the rest to prevent combined top/inline posting reordering time]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to