(Randal L. Schwartz) wrote:
Hi Randal
>>>>>>"Rob" == Rob Dixon <[EMAIL PROTECTED]> writes:
>
>
> Rob> I favour
>
> Rob> print FILE "$_\n" foreach grep /[^.]/, readdir DIR;
>
> Rob> for clarity
>
> But certainly not for correctness! It's easy to look pretty if you don't care
> about the right answer. Your regex rejects *any* filename that contains *any*
> dot. On a windows system, that'd be just about any file. :)
>
> Nahh, best to ignore yours and look upthread heere.
Look again. My regex rejects any filename that contains /only/ dots. /[^.]/
matches any character that isn't a dot.
>
>>>closedir DIR;
>>>close FILE;
>
>
> Rob> Or even
>
> Rob> system "dir /b $path > C:/filelist.txt";
> Rob> $? and die "Can't create C:/filelist.txt: $?"
>
> Rob> since portability is not a question
>
> Apparently, since your code isn't portable either. :)
I don't understand this comment. The only lack of portability I can see is in
the form of the file paths, which was in the original post.
>>>s/("[^"]*)("\s+"[^"]*)("\s+"[^"]*)("\s+NA)/$1$file$2$file$3$file$4/;
>
>
> Rob> Again, I think
>
> Rob> s/("[^"]*)(")/$1$file$2/g;
>
> Rob> is less befuddling.
>
> And less correct.
I don't see why? This was the request:
>>> 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
John's approach was to match the strings
'"SL/'
'" "%HOME%/server/bin/'
'" "'
and
'" NA'
and to put them back into the replacement string with the filename interposed. I
saw it more simply as just putting the filename before the closing quote of all
embedded quoted strings. Either way, my code works with the given data, so
unless you've seen a case where it doesn't hold up I can't see the problem.
> Hmm. Your track record isn't good on this post.
Please explain youself Randal. Or did you just wake up in troll mode today?
> Perhaps you should read and learn more before answering, because a bad answer
> is a lot more damaging than *no* answer, especially when correct answers
> have already been given elsewhere in the thread.
I do read and I do learn, and learning is one of my main reasons for subscribing
to this mailing list. A bad answer is certainly damaging, but I still don't
think my post was wrong. Perhaps more destructive still is an abusive rejoinder.
> We appreciate your enthusiasm to help. But in this case, "help" means
> "please spend more time reading and less time posting". Or at least
> check your answers before posting... that would have been caught here.
I checked my answers before posting them. Did you check them before rubbishing
them?
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>