The most direct way I can think of would be to simply open the file again and read each line writing it to another file exactly as you want.
I'm still rather inexperienced with perl myself so I wouldn't know off-hand how to do this exactly. Mathew Nishi Bhonsle wrote: > Mathew: > > Thanks. I modified the code and it works now to ignore the "." and ".." > . Can you advise me on how to insert the $y into another file that > contains the lines of the foll format -- > "SL/" "%HOME%/server/bin/" "" NA > so, that the resultant line in the file is > "SL/$y" "%HOME%/server/bin/$y" "$y" NA > > ---------------------------------------------------------------------------------------------------------------------- > $path = "$ARGV[0]"; > opendir ( DIR, $path ) or die "Can't open $path: $!"; > while(defined($DIR = readdir DIR)) > { > push(@array_A,$DIR) > } > closedir DIR; > open(FILE,">c:/filelist.txt"); > foreach $y (@array_A) > { > next if $y =~ /^\./; > print "$y\n"; > print FILE "$y\n"; > } > close FILE; > > On 7/8/06, *Mathew Snyder* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > > > Nishi Bhonsle wrote: > > I was able to writeout the files on a filesystem to a file > C:/filelist.txt > > using the program - > > > > $path = "$ARGV[0]"; > > opendir ( DIR, $path ) or die "Can't open $path: $!"; > > while(defined($DIR = readdir DIR)) > > { > > push(@array_A,$DIR) > > } > > closedir DIR; > > open(FILE,">c:/filelist.txt"); > > foreach $y (@array_A) > > { > > print "$y\n"; > > print FILE "$y\n"; > > } > > close FILE; > > > > Can you please tell me how to modify the above program to ignore > the "." > > and > > "..", so that they donot get printed in C:/filelist.txt ? > > I use this line just above the print command that writes the > filename/director name: > > next if $_ =~ /^\./; > > > > > Can you also let me know how to read the line in the below file, > look for > > the second and forth " and write the name of the file fetched in the > > above program before the second and fourth " and between the fifth and > > sixth > > " one by one. > > > > "SL/" "%HOME%/server/bin/" "" NA > > as in > > "SL/one" "%HOME%/server/bin/one" "one" NA > > > > > > Thanks again. > > > > > > > > On 7/7/06, Mr. Shawn H. Corey <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > >> > >> Nishi Bhonsle wrote: > >> > Hi: > >> > > >> > Can you please help me write a perl script that takes the files > from a > >> > directory and spits out the filenames into a file. > >> > say. > >> > I have a file structure on a file system such as > >> > C:\Temp\one > >> > C:\Temp\two > >> > C:\Temp\one\oneone > >> > C:\Temp\one\onetwo > >> > C:\Temp\one\onethree > >> > > >> > The original file contains lines in the foll format -- > >> > "SL/" "%HOME%/server/bin/" "" NA > >> > > >> > This original file will be updated by the perl script to > contain the > >> > filenames in the foll manner -- > >> > "SL/one" "%HOME%/server/bin/one" "one" NA > >> > "SL/oneone" "%HOME%/server/bin/oneone" "oneone" NA > >> > "SL/onetwo" "%HOME%/server/bin/onetwo" "onetwo" NA > >> > etc > >> > > >> > Please help. > >> > > >> > Thanks a lot! > >> > > >> > >> See `perldoc File::Find` and `perldoc File::Basename` > >> > >> > >> -- > >> __END__ > >> > >> Just my 0.00000002 million dollars worth, > >> --- Shawn > >> > >> "For the things we have to learn before we can do them, we learn by > >> doing them." > >> Aristotle > >> > >> * Perl tutorials at http://perlmonks.org/?node=Tutorials > >> * A searchable perldoc is at http://perldoc.perl.org/ > >> > >> -- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > >> For additional commands, e-mail: [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > >> <http://learn.perl.org/> <http://learn.perl.org/first-response> > >> > >> > >> > > > > -- > If we don't protect freedom of speech, how will we know who the assholes > are? > > -- If we don't protect freedom of speech, how will we know who the assholes are? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>