Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Using the map function

by 2teez (Priest)
on Jul 10, 2013 at 18:28 UTC ( #1043525=note: print w/ replies, xml ) Need Help??


in reply to Using the map function

Hi cspctec,
For me, using HASH of ARRAYs, could easily get this done for you like so:

use warnings; use strict; use Data::Dumper; my %hash; while (<DATA>) { chomp; next if /^\s*$/; my $key = $1 if /\w+?\s+?(.+?)\s+/; push @{ $hash{$key} }, $_; } print Dumper \%hash; __DATA__ CPU Temp = 30 GFX Temp = 45 RAM Temp = 40 CPU Status = OK GFX Status = OK RAM Status = OK
... produces ...
$VAR1 = { 'Temp' => [ 'CPU Temp = 30 ', 'GFX Temp = 45 ', 'RAM Temp = 40 ' ], 'Status' => [ 'CPU Status = OK ', 'GFX Status = OK ', 'RAM Status = OK' ] };

For more info. Please see perldsc
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: Using the map function
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-08-02 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (54 votes), past polls