On Tuesday 25 July 2006 15:56, Rob Dixon wrote:
> Nishi Bhonsle wrote:
>  > I got the last soln, ie to use File::Basename module. Please ignore the
>  > last thread.
>  >
>  > I am still interested to know why Rob's soln doesnt work for me?
>
> So was I, and it's because I made a mistake. Because the values returned by
> readdir don't include a full path,  the file test only works if the
> directory being listed is the current one. Try this version instead with my
> humble apologies.
[ snip ]

I'd experimented *before* I saw this post.

#!/usr/bin/perl
   use strict;
   use warnings;

   my @dir = do {
#     opendir my $dh, 'C:\build\Sample\NewDir' or die $!;
     opendir my $dh, '/home/al/temp4' or die $!;
#     grep -f, readdir $dh;
     readdir $dh;
   };

   print "$_\n" foreach @dir;
# print @dir, "\n";


That works on Linux (not matters the current dir, I was in /home/al when I ran 
it) which leads me to guess that something be wrong with the grep line.

Also, on Windows, doesn't it need to be either C:\\build\\Sample\\NewDir

or

C:/build/Sample/NewDir

In my past Win days, I used to do it like that latter.

I'm guess maybe it's must do that when it's double quotes.  I see you used 
single quotes.

-- 
Alan.

-- 
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