in reply to Unable to read a file
Any other suggestions or feedbacks on this are welcome. Thanks everyone.#!/usr/bin/perl use warnings; use strict; print "Enter the path where the log file is placed : "; my $dir =<>; chomp($dir); opendir DIR, $dir or die "cannot open dir $dir: $!"; my @files= readdir DIR; my $len=scalar(@files); print $len; print "Enter the path where to save the report"; my $dest_dir = <STDIN>; chomp($dest_dir); open(FH1,">$dir./result.txt") if( $len > 0); foreach my $file (@files){ if($file=~/\.txt/){ print "$file\n"; open(FH,"$dest_dir./$file") or die $!; while(my $line= <FH> ){ print FH1 $line; } close FH; } } close FH1; closedir DIR;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unable to read a file
by Ken Slater (Initiate) on Jun 13, 2012 at 16:11 UTC |