Hello everyone, I am new to Perl and am trying to code a simple program that will read a list of files from a text file then present the user with some options regarding those files (hope that makes some sense). Unfortunately after much searching/reading on the web and playing around with the code I have come up with so far I am stuck with the same warning (Use of uninitialized value in print). The code I have come up with is below
#!perl -w # File Name = aaaa.pl # Date Monday, April 04, 2005 @files1to5 = (); $list1 = ""; open (TEXT, "list.txt") or die "Error. No such file\n"; @rawtext=<TEXT>; close(TEXT); print "\n"; $list1 = @rawtext; @files1to5 = split (/\$/, $list1); print "Please enter the file you wish to select..\n\n"; chomp($selectitem = <STDIN>); if($selectitem == 1) { print "\n"; print "You selected item 1,\n"; print $files1to5[0]; $item = 1; } elsif($selectitem == 2) { print "\n"; print "You selected item 2,\n"; print $files1to5[1]; $item = 2; } elsif($selectitem == 3) { print "\n"; print "You selected item 3,\n"; print $files1to5[2]; $item = 3; } elsif($selectitem == 4) { print "\n"; print "You selected item 4,\n"; print $files1to5[3]; $item = 4; } elsif($selectitem == 5) { print "\n"; print "You selected item 5,\n"; print $files1to5[4]; $item = 5; } else { print "\n"; print "Invalid item selection! No such item\n"; } If I select item 1, the code fails on the line print $files1to5[0]; with the output D:\My Documents\Perl>aaaa.pl Please enter the file you wish to select.. 1 You selected item 1, Use of uninitialized value in print at D:\My Documents\Perl\aaaa.pl line 20, <STDIN> line 1. and similarly for the other possible selections. I'm sure this is something glaringly simple that i'm overlooking, yet I still cannot work it out. Any assistance would be much appreciated. Thanks -- [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>