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

Re^4: opening many files

by wanttoprogram (Novice)
on Feb 28, 2012 at 04:44 UTC ( #956576=note: print w/ replies, xml ) Need Help??


in reply to Re^3: opening many files
in thread opening many files

thank you. the code is working fine. could you please help me understand the code. i am a beginner in perl and had hard time understanding the hi-fi code. also could you please explain how sort is working in your code. what changes do i have to make to code to get all the data with out any sorting. thank you.


Comment on Re^4: opening many files
Re^5: opening many files
by Anonymous Monk on Feb 28, 2012 at 05:08 UTC

    understanding the hi-fi code

    What code are you calling the hi-fi code?

      @ARGV = glob 'datafile*'; open my $OUTPUT, '>', 'output_file' or die "Cannot open 'output_file' +because: $!"; my %data; while ( <> ) { next unless /^(.+) (\S+)$/; push @{ $data{ $1 } }, $2; } for my $key ( sort keys %data ) { print join ' ', $key, @{ $data{ $key } }, scalar @{ $data{ $key } +}, "columns\n"; }
      ======================== I have files by name datafile1,datafile2,datafile3,datafile4.........datafile200 in a directory. But these files are stored in a a different pattern ...datafile1,datafile10,datafile11,datafile12 and so on. The above program is reading and writing in the same order. I would like to pick data from in the an order from datafile1, 2, 3 to data200. Any suggestions and additions are appreciated. Thank you.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2015-07-02 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (34 votes), past polls