Adding a line in a file inside many directories
- From: vedpsingh@xxxxxxxxx (Ved)
- Date: Thu, 28 Jun 2007 21:04:18 -0700
Hi all,
I am a beginer in PERL.
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);
#########
.
- Follow-Ups:
- Re: Adding a line in a file inside many directories
- From: Tom Phoenix
- Re: Adding a line in a file inside many directories
- Prev by Date: Re: using a homemade perl module
- Next by Date: processing XL using Win32::OLE
- Previous by thread: Re: Adding a line in a file inside many directories
- Next by thread: Re: Adding a line in a file inside many directories
- Index(es):
Relevant Pages
|
|