Hi,

The code you have should work, but you might want to use the opendir function
because your current code does not display, hidden files and files you
don't have read access on

This code does:

opendir(DIR,"/path/to/files") || die "Unable to read from directory.\n";
while ( defined ($filename = readdir (DIR))) {
  next if $filename =~ /^\.\.?$/;
  next if (!-f "/path/to/files/$filename");
  print $filename . "\n";
}
closedir(DIR);


and it might solve your spaces problem as well :)
tchau,

Jan-Willem



On Thu, 8 Nov 2001, Olav Rogall wrote:

> Hallo beginners-cgi,
>
>   i'm using this script, to print out a list of the file's in a
>   directory.
>
> #!/usr/bin/perl -w
>
> foreach $fh (</path/to/files/*.txt>) {
> print $fh."\n";
> }
> exit;
>
> with the filename "this_is_a_text.txt" the output is
> "this_is_a_text.txt". if there are no _ (the files were created by a
> w2k-machine over the net) but spaces, the output from the file "this
> is another text.txt" is "this".
>
> how can i do it, that $fh has "this is another text.txt"?
>
> --
>
> MfG...
>       ...Olav
>
> FidoNet: 2:240/5138
>
>
>
> --
> 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]

Reply via email to