Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (15)
As of 2015-07-29 11:34 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 (263 votes), past polls