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

Re: print out the values from a hash

by Kenosis (Priest)
on Jan 11, 2013 at 18:11 UTC ( #1012943=note: print w/replies, xml ) Need Help??

in reply to print out the values from a hash

choroba has provided excellent suggestions. Here an option that uses a hash of arrays (HoA), where the key is the file name and its associated value is a reference to a list of frequencies:

use strict; use warnings; my %files; for my $file (<*.abc>) { open my $fh, '<', $file or die $!; while (<$fh>) { push @{ $files{$file} }, $1 if /FREQ\s+([\d.]+)/; } close $fh; } print "$_ FREQ @{ $files{$_} }\n" for keys %files;

Output on files containing FREQ <val> info: FREQ 27.047 400 FREQ 33.3 2.22 FREQ 12345.67

Hope this helps!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012943]
[1nickt]: Quick survey: has anyone used or even heard of autobox?
[Corion]: thezip: I would expect some (fancier?) numeric formatting to fail from these test failures
[1nickt]: ( Sometimes when idle I browse remote corners of the code repo at $work ... usually this yields knowledge of projects to decline and coworkers to avoid ... )
[LanX]: sure
[Corion]: 1nickt: Finding autobox in production would give me pause, yes
[LanX]: efficient survey
[MidLifeXis]: And under MINGW64_NT-6.1 MYHOST 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys there seem to be issues with escapes in external build tool calls.
[Corion]: I mean, it's a technical feat it achieves, but... why? ;)
[MidLifeXis]: And it also has the 0.14 version of the tarball in its manifest.
[LanX]: avoiding unreadable brackets

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2017-03-23 17:22 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (291 votes). Check out past polls.