> > From: Josef E. Galea[SMTP:[EMAIL PROTECTED]] > > To: [EMAIL PROTECTED]
> Hi > I am a student an I'm new to Perl. For a university assignment I need > to > read the contents of a text file in an array. I am using Windows. The > code I am writing is: > > $file = "/test.txt"; > open (INFO, "$file"); > @lines = <INFO>; > close(INFO); Does this help any. #!perl # # These are a must of course. use strict; use warnings; # Note I am trying to avoid flames # by including all the usaul # warnings stricts etc # my $CurrentLine; # # Please enter your own pathname # open (INFILE, "c:\\hello.txt") || die "Unable to open file $!"; while ( defined($CurrentLine = <INFILE>)) { print STDOUT "$CurrentLine"; }; close(INFILE); exit 0; > > Altough this is supposed to work, I am getting a ''readline() on > closed > filehand INFO at line 3' message when I interpret it with perl -w. > Please Help You are getting a readline error because the file has not been opened. If you look at my code above you will notice I have included the die statement after the attempt at vreating my file handle. This would have given you an easier error to debug __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]