On 04/04/2005, [EMAIL PROTECTED] wrote: > open (TEXT, "list.txt") or die "Error. No such file\n"; > @rawtext=<TEXT>; > close(TEXT);
According to your own follow-up, @rawtext will have the following content: $rawtext[0] = '$file1.txt$' . "\n"; $rawtext[1] = '$file2.txt$' . "\n"; etc ... > $list1 = @rawtext; @rawtext is evaluated in scalar context (because of the scalar lvalue). This gives the number of elements in @rawtext (or equivalent, the number of lines in your file) - this is an integer > @files1to5 = split (/\$/, $list1); @files1to5 will have one element, $files1to5[0], containing the number of lines in your file - this is probably not what you want... I would do it like this: #! perl use warnings; use strict; my $infile = 'list.txt'; open (TEXT, $infile) or die "$infile: $!"; chomp(my @data = map { /^\$(.*)\$$/ } <TEXT>); close(TEXT); my $prompt = "\nPlease enter the file you wish to select (q to quit): "; print $prompt; while ( chomp(my $selecteditem = <STDIN>)) {; last if $selecteditem eq 'q'; if ($selecteditem =~ /^(1|2|3|4|5)$/) { print "You selected item $1, \n$data[$1-1]\n"; } else { print "Invalid input '$selecteditem'\n"; } print $prompt; } (And you won't need the map {...} stuff if your input file doesn't contain the $ before and after the filenames.) -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>