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

Re^2: Generation of Array of hashes by reading a file

by NetWallah (Canon)
on Jan 04, 2018 at 21:27 UTC ( [id://1206717]=note: print w/replies, xml ) Need Help??


in reply to Re: Generation of Array of hashes by reading a file
in thread Generation of Array of hashes by reading a file

Slightly shorter loop:
# After "open" .. my %wanted = map {$_=>1} qw|media inet status ether|; while (<$fh>) { chomp; if (/^(\w+\d{1}):\s+flags=(.*?>)/) { $rec = {}; push @AoH, $rec; $rec->{'interface'} = $1; $rec->{'flags'} = $2; next; } if (/(\w+):?\s+(.*$)/ and $wanted{$1}) { $rec->{$1} = $2; } }

                We're living in a golden age. All you need is gold. -- D.W. Robertson.

Log In?
Username:
Password:

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

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

    No recent polls found