Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Create a Hash Dynamically and add the values of same key

by hbm (Hermit)
on Jun 18, 2013 at 14:08 UTC ( [id://1039567]=note: print w/replies, xml ) Need Help??


in reply to Create a Hash Dynamically and add the values of same key

Suggestions for your MAP loop - rather than:

while ( <MYFILE> ) { chomp; (my $txnid,my $date,my $custid,my $amount, my $productc, my $subc, +my $city, my $state, my $mode) = split(","); my $key_to_reduce = join ".", "$subc", "$state"; print "$key_to_reduce\t$amount\n"; }

This?

while ( <MYFILE> ) { # not needed if you don't use last field # chomp; # one 'my' for a list; grab only the needed fields my ($amount, $subc, $state) = (split/,/)[3,5,7]; # no need for join: my $key_to_reduce = "$subc.$state"; print "$key_to_reduce\t$amount\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1039567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found