I think I am getting close. With much help I have been able to tweek my original code down quite a bit. For the most part, everything is working as it should. What is stumping me right now is, how do I make sure that both the part number and the rev match before printing out the record. The part number is in $fields[0], the rev is in $fields[1]. The two fields are seperated by a pipe. I am attempting to send both inputs to the subroutine as arguments. thanks for any hints towards the right direction. #!/usr/bin/perl -w use strict; use Data::Dumper;
print "Enter the Part Number you wish to search for: "; my $part = <STDIN>; chomp($part); print "Enter the Revison for ($part): "; my $rev = <STDIN>; chomp($rev); my $searchresult = &search(part => $part, rev => $rev); if (defined $searchresult) { print "Located Part Number $part: $$searchresult[1]\n";<-- How can I print all the fields without typing in each field }else { individually? print "Your Part Number ($part) could not be found...\n"; } # This routine will accept a part number and rev as anonymous # hashes, and search thru a text file returning the entire # record (pipe delineated) of the 1st occurence sub search { my %args = @_; my $retval; local *FH; open (FH, './fai.txt') || die "Cannot open file: ($!)"; my @parts = <FH>; my @rev = <FH>; foreach my $line (@parts, @rev) { my @fields = split(/\|/, $line); if ($args{part} eq $fields[0], $fields[1]) { <-- this is as close as I have gotten so far $retval = \@fields; last; } } close FH; return $retval; } 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>