Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: Reading Multiple files

by bimleshsharma (Beadle)
on Aug 07, 2012 at 12:48 UTC ( #985966=note: print w/ replies, xml ) Need Help??

in reply to Re: Reading Multiple files
in thread Reading Multiple files

Here is sample:See if this can help you.

opendir $dh, $dir_of_files or die "Couldn't open dir '$dir_of_files': +$!"; my @comparefiles= readdir $dh; closedir $dh; for each $file in @comparefiles { read_write_subroutine($file); } sub read_write_subroutine { put your whole code here which is currently you are using }

Comment on Re^2: Reading Multiple files
Download Code
Replies are listed 'Best First'.
Re^3: Reading Multiple files
by maheshkumar (Sexton) on Aug 07, 2012 at 16:50 UTC

    Hoe to generate different file names for the output?


      Any way you like. You could do something like:

      my $output_filename="OUTPUT.001"; for my $filename (@filelist) { do_stuff($filename, $output_filename); ++$output; }

      But it would most likely be less confusing to just tack on a new suffix, or squirrel the file away in a different directory:

      for my $filename (@filelist) { my $output_filename = $filename . ".processed"; do_stuff($filename, $output_filename); }


      When your only tool is a hammer, all problems look like your thumb.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2015-10-04 16:46 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (103 votes), past polls