Ayesha wrote:
Hi all
I wrote this code to read a file (in the same directory as the script)
on Win XP
***************************************************************************************************
#!/usr/local/bin/perl
use strict;
use warnings;
open(READFILE1,"<./Sample_text_file.txt") or die ("Cannot open the
given file");
my $record;
while ($record = <READFILE1>) {
print $record;
}
close READFILE1;
#print "Is this even working? \n"
****************************************************************************************************
It is gives me output that "Cannot open the given file". However, the
same program is working on linux/mac platforms, i.e. can open files
and read them. To check that I have perl correctly installed I added a
print statement at the end. When I block everything regarding opening
the file and just have the print statement in the script, the script
works OK, implying Perl is installed correctly. Can anyone tell me
what is wrong. Can anyone tell me what am I doing wrong here? It seems
some Windows specific thing.
Change your open call to:
open READFILE1, 'Sample_text_file.txt' or die "Cannot open the file: $!";
and you will see additional information as to why the file couldn't be opened.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/