Re: reading from directories = no values
Karsten Borgwaldt wrote: 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! {push(@my_array, $_;} typo or copy problem that you don't close 'push (' ? } did you try opendir(IN, the_dir) || die opendir: $!; rewinddir(IN); while ($_ = readdir (IN)) { if (m/^\.{1,2}$/ or m/'.foo'$/) { print STDERR wrong file ($)\n; } else { print STDERR here's a file ($_)\n; } } to see if it ever finds any files? /Jon .. .. .. 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. Thank you for all suggestions. Karsten Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: reading from directories = no values
-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]