Ganesh Shankar wrote: > > Hello all, Hello,
> I tried modifying the open command ar suggested and got the enclosed > errors. Also, I'm working with Activestate Activeperl 5.6 on a Windows > 2000. Also, from the syntax of the readdir example, the test is to the > left of the readdir command. Does this mean I should place my file > processing block to the left of the readdir command. That would be one > ugly statement. > > [snip] > > use warnings; > use strict; > > my @files = (); > my $folder = 'input'; > # Open the input folder > unless (opendir(FOLDER, $folder)) { > print "Cannot open folder $folder!\n\n"; > exit; > } > > #read the contents of the folder (files and subfolders) > > chdir($folder); #added this line after failing with open commands below. > > print "Switching to folder $folder!\n\n"; # It's going to the correct > folder > > @files = readdir(FOLDER); > > #Close the folder > > print "\n\n Here are the files in the folder\n"; > #print out the filenames, one per line > print join( "\n", @files), "\n";# Prints out correct filenames > > closedir(FOLDER); > > foreach my $seqfilename (@files){ > > $seqfilename = ''; > open (TXTFILE,"<$seqfilename") or die $!; #dies on this line.Replace with This won't work because it is trying to open $seqfilename in the current directory. > open (TXTFILE,"<$folder/$seqfilename") or die $!; #Invalid argument at this > line. Replace with Windows apparently sends an EINVAL ("Invalid argument") when there are certain non-printable characters in the file name! (Who knew?) http://mail.python.org/pipermail/python-list/2002-March/090323.html > open (TXTFILE,"<$folder\$seqfilename") or die $!; #No such file or directory > error at this line This won't work because the backslash will escape the dollar sign. If you want the backslash character in a double quoted string you will have to escape it (precede it with a backslash.) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]