Re: Adding a line in a file inside many directories
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Fri, 29 Jun 2007 06:18:16 +0200
Ved wrote:
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.
<snip>
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
open (dirIN, "$file_list/kat.s") or ...
But that will only open the file for reading. Furthermore, since you want to add a line at a specific position in the file, I think you should consider the advice in this FAQ entry:
perldoc -q "insert a line"
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- Follow-Ups:
- Re: Adding a line in a file inside many directories
- From: Gunnar Hjalmarsson
- Re: Adding a line in a file inside many directories
- References:
- Prev by Date: Adding a line in a file inside many directories
- Next by Date: Re: Oh great gurus of the list, I need help with a regular expression please
- Previous by thread: 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
|
|