Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Unable to read a file

by pvaldes (Chaplain)
on Jun 13, 2012 at 08:44 UTC ( #975939=note: print w/ replies, xml ) Need Help??

in reply to Unable to read a file

Similar but a little more compact

#!/usr/bin/perl -w use strict; use autodie; print "Enter the path where the log file is placed: "; chomp(my $dir = <STDIN>); opendir DIR, $dir; my @text = grep (/\.txt$/, readdir DIR); # <--- note the '$' here closedir DIR; print "Enter the path where to save the report: "; chomp(my $dest_dir = <STDIN>); open (my $FH1, '>', "$dest_dir/result.txt") if( scalar(@text) > 0); foreach my $textfile (@text){ print $FH1 $textfile,"\n"; } close $FH1;

Comment on Re: Unable to read a file
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2016-02-11 07:26 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (362 votes), past polls