in reply to pulling information from a delineated text file using a subroutine
Yes, that is exactly what you did. You declared @fields inside of search, and that is the only place it is known, because "my" creates a scoped variable. It goes out of scope outside the subroutine.
That wouldn't have been a problem if you only used @fields inside search, which I think you meant to do. But because you accidently doubled the "}" right after the end of the while loop, you ended the subroutine definition right there. You need to move that "}" to the end of the program, and then the use of @fields will still be in scope for the print statement.
P.S.: Other than the "<" fix, the other suggestions by Ovid are more a matter of good programming style than they are fixes to make your program work correctly. Ovid is suggesting that you pass in the file name as a parameter, like this:
&search("fai.txt", $PartNumber, $Revision);
|
|---|