Greetings, I have a quick question. In the code below I get an error message that says 'Global symbol "@fields" requires explicit package name' The line that causes the error is highlighted in red. Obviously it has to do with how I declared the variable in my subroutine. I tried moving curly brackets and I tried other ways of declaring. Could someone please tell me the correct way to do this. The perldoc's are still somewhat cryptic to me. I thought that moving the close(FILE) would help, but it did not.
#this is the subroutine to search the file sub search{ open(FILE, '<fai.txt') || die $!; <-- Also, is this statment correct to open a file for read only? while (<FILE>) { chomp; # remove newline my @fields = split(/\|/, $_); # test whether the search string matches part number if ($fields[0] =~ /$PartNumber/ ) { print "$PartNumber Rev. $Revision has a First Article Report\nWould you like to view it?"; } }} my $answer = <STDIN>; chomp($answer); # If the answer is yes then fill the form with the information if ($answer eq "yes") { print "\n\n\none second please......\n"; print "retrieving file........\n"; print "$fields[0]: $fields[1]: $fields[2]: $fields[3]\n"; } # If the answer is no then die else { print "ok, well have a nice day.\n"; } close(FILE); Kerry LeBlanc Materials Auditor Process Owner 75 Perseverence Way Hyannis, MA. 02601 1-508-862-3082 http://www.vsf.cape.com/~bismark <http://www.vsf.cape.com/~bismark>