> -----Original Message-----
> From: Karsten Borgwaldt [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 09, 2002 10:29 AM
> To: [EMAIL PROTECTED]
> Subject: reading from directories => no values
> 
> 
> Hi all,
> 
> can anybody tell me, why I can't push any read values into an array?
> 
> my code is:
> ..
> ..
> ..
> opendir(IN, "some_path") || die "opendir: $!";
> rewinddir(IN);
> while (defined($_ = readdir(IN)))
>   {unless (m/^\.{1,2}$/ or not m/'.foo'$/) # all files, that 
> are not "." or ".." and that end ".foo"!

Those single quotes are part of what needs to be matched. So the
file needs to end with "'.foo'", not just ".foo". Also, you need
to escape the ., since that is a special regex char. I think
you might want:

   m/\.foo$/

Also, if the file has to end with .foo, why bother checking
for . and .., since those don't end with .foo?

Couldn't you just say:

   push @my_array, $_ if /\.foo$/;

Or am I misunderstanding what you're trying to do?

>     {push(@my_array, $_;}

(You're missing a right-paren here.)

> }
> ..
> ..
> ..
> I get no errors, but nothing happens.
> If I insert the line
> 
> foreach $item (@my_array) {print "$item";}
> 
> I get no errors, too, but no values are printed.
> Allthough I know there are files in that directory.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to