Nishi Bhonsle wrote:
>
> Rob:
>
> Thanks for your input.
> Can you tell me how I could define $file in the below snippet so, i can
> subsitute the filename ie $file into the files2.txt that contains lines
> of the format
> "SL/" "%HOME%/server/bin/" "" NA
>
> Thanks a lot!
>
--------------------------------------------------------------------------------
> use warnings;
> use strict;
>
> my $path = $ARGV[0];
>
> #system "dir /b $path > C:/filelist.txt";
> #$? and die "Can't create C:/filelist.txt: $?"
>
> open FILE, '>', 'c:/filelist.txt' or die "Can't open c:/filelist.txt: $!";
> opendir DIR, $path or die "Can't open $path: $!";
>
> print FILE "$_\n" foreach grep /[^.]/, readdir DIR;
>
> closedir DIR;
> close FILE;
>
> open FILE1, '>', 'c:/TestPerlProg/files2.txt' or die "Can't open
> c:/TestPerlProg/files2.txt: $!";
>
> s/("[^"]*)(")/$1$file$2/g;
>
> close FILE1;

Hi.

Please keep your posts to the mailing list so that other people can help as 
well.
I've copied this reply there myself.

I'm not exactly clear what you need to do. Looking at your original post you
needed to find files at all levels within the directory:

>>> C:\Temp\one
>>> C:\Temp\two
>>> C:\Temp\one\oneone
>>> C:\Temp\one\onetwo
>>> C:\Temp\one\onethree

but then you posted a solution which just opened a single directory and listed
the files from there. Which is it tht you need? It's also important to note that
your list will include both files and directories; again, is this correct?

You say you have a file with lines like:

  "SL/" "%HOME%/server/bin/" "" NA

where you want to insert the filename in each of the quoted strings. Are you
expecting to create a new output file for each of the filenames in the list, or
are all the names incorporated into files2.txt somehow? Does your file contain
/only/ lines like this or do we need to choose the ones that are modified? Do 
you
really want to insert only the filename, with no mention of its path? A sample 
of
the object file that contains these lines would help a lot. Finally, do you need
to create filelist.txt or is it only for the purpose of creating the target
file(s).

Let us know these details and we will be able to help you much better.

Cheers,

Rob


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to