Thank you everyone. I'm still digesting this, but I do have a better
understanding.
Chris
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
At 10:41 AM +0800 3/23/12, lina wrote:
On Fri, Mar 23, 2012 at 10:20 AM, John W. Krahn wrote:
John W. Krahn wrote:
$ echo "Hr 12
0001 2
0002 3
0003 1
Hr 13
0001 2
0002 3
0003 1
Hr 14
0001 2
0002 3
0003 1" | perl -e'
my ( @hours, %data );
while ( <> ) {
push @hours, $1 if
On Fri, Mar 23, 2012 at 10:20 AM, John W. Krahn wrote:
> John W. Krahn wrote:
>>
>>
>> $ echo "Hr 12
>> 0001 2
>> 0002 3
>> 0003 1
>> Hr 13
>> 0001 2
>> 0002 3
>> 0003 1
>> Hr 14
>> 0001 2
>> 0002 3
>> 0003 1" | perl -e'
>>
>> my ( @hours, %data );
>> while ( <> ) {
>> push @hours, $1 if /^hr\s
John W. Krahn wrote:
$ echo "Hr 12
0001 2
0002 3
0003 1
Hr 13
0001 2
0002 3
0003 1
Hr 14
0001 2
0002 3
0003 1" | perl -e'
my ( @hours, %data );
while ( <> ) {
push @hours, $1 if /^hr\s*(\d+)/i;
$data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/;
}
print join( "\t", "", @hours ),
Chris Stinemetz wrote:
I would like to use the number on the left as a key in a hash and use
the number on the right as the value pair to the key. Then print the
values for each hour that have the same key. Maybe this is a good
example for an array of hashes, but I not real sure how to begin. Any
On 12-03-22 05:23 PM, Chris Stinemetz wrote:
but I not real sure how to begin. Any
help is greatly appreciated.
Below is the input data:
Hr 12
0001 2
0002 3
0003 1
Hr 13
0001 2
0002 3
0003 1
Hr 14
0001 2
0002 3
0003 1
Desired output below:
12 13 14
00012 2 2
00023 3 3
On 3/22/12 Thu Mar 22, 2012 2:23 PM, "Chris Stinemetz"
scribbled:
> I would like to use the number on the left as a key in a hash and use
> the number on the right as the value pair to the key. Then print the
> values for each hour that have the same key. Maybe this is a good
> example for an a