Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Multiple Extraction from Multiple Files

by toolic (Chancellor)
on Oct 07, 2010 at 01:06 UTC ( #863891=note: print w/ replies, xml ) Need Help??


in reply to Multiple Extraction from Multiple Files

You might find it easier to work with a data structure like this one:

use warnings; use strict; use Data::Dumper; use List::Util qw(min max); my %data; while (<DATA>) { my ($file, $name, @nums) = split; push @{ $data{$file}{$name} }, min(@nums), max(@nums); } print Dumper(\%data); __DATA__ File1 abc 1000 1010 File2 xyz 2022 3000 File1 def 3211 2300 File4 ghi 4000 4100 File3 jkl 5002 5100 File4 mno 2001 2500 File5 pqr 100 150 File3 Ade 203 340 File2 Sea 101 201

This prints out:

$VAR1 = { 'File2' => { 'Sea' => [ '101', '201' ], 'xyz' => [ '2022', '3000' ] }, 'File5' => { 'pqr' => [ '100', '150' ] }, 'File3' => { 'Ade' => [ '203', '340' ], 'jkl' => [ '5002', '5100' ] }, 'File1' => { 'def' => [ '2300', '3211' ], 'abc' => [ '1000', '1010' ] }, 'File4' => { 'mno' => [ '2001', '2500' ], 'ghi' => [ '4000', '4100' ] } };


Comment on Re: Multiple Extraction from Multiple Files
Select or Download Code
Re^2: Multiple Extraction from Multiple Files
by snape (Pilgrim) on Oct 07, 2010 at 21:07 UTC
    Thanks a lot that works !!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2014-08-30 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls