V
Ved
Hi all,
I am a beginer in PERL.(I have posted this message in perl.beginers
also and is with moderators)
What I am trying to do is this:
I have a 150 directories, each having a file "kat.s" in them.
I have names of all these directories in a text file
"list_of_dir.txt".
I have to open the each of "kat.s" in all the 150 directories and add
a line(say "ABCD" at line number 20) in each of them.
What I have thought of doing is that using "list_of_dir", open each
directory and open kat.s and print the required statment.
I have written a code. But I am stuck in opening the directory and
than kat.s file.
Please help.
(Or suggest any better way to do it)
Thanks.
#######
use strict;
use warnings;
my $file = 'print.txt';
open my $VEDOUT, '>', $file or die "Could not open '$file': ";
open (VEDIN, 'list_of_dir.txt') or die "Cannot open 'File.txt' $!";
my @rgstr=<VEDIN>;
foreach my $file_list (@rgstr) {
print $file_list ; #printing list of dir
open (dirIN, '$file_list/kat.s') or die "Cannot open 'File.txt' $!";
#This is not working
}
close (VEDIN);
close ($VEDOUT);
#########
I am a beginer in PERL.(I have posted this message in perl.beginers
also and is with moderators)
What I am trying to do is this:
I have a 150 directories, each having a file "kat.s" in them.
I have names of all these directories in a text file
"list_of_dir.txt".
I have to open the each of "kat.s" in all the 150 directories and add
a line(say "ABCD" at line number 20) in each of them.
What I have thought of doing is that using "list_of_dir", open each
directory and open kat.s and print the required statment.
I have written a code. But I am stuck in opening the directory and
than kat.s file.
Please help.
(Or suggest any better way to do it)
Thanks.
#######
use strict;
use warnings;
my $file = 'print.txt';
open my $VEDOUT, '>', $file or die "Could not open '$file': ";
open (VEDIN, 'list_of_dir.txt') or die "Cannot open 'File.txt' $!";
my @rgstr=<VEDIN>;
foreach my $file_list (@rgstr) {
print $file_list ; #printing list of dir
open (dirIN, '$file_list/kat.s') or die "Cannot open 'File.txt' $!";
#This is not working
}
close (VEDIN);
close ($VEDOUT);
#########