I made some changes. Now I get an error message.

The message says "Can't use string ("") as an ARRAY ref while "strict refs" in use"

Here is the code as it stands now, with changes.



#!/usr/bin/perl -w

use strict;
use Data::Dumper;
use diagnostics -verbose;


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..7]\n";
        
}else {
        print "Your Part Number ($part) Rev ($rev) could not be found...\n";
}


# This routine will accept a part number as an anonymous
# hash, 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 @records = <FH>;
        chomp (@records);
               foreach my $line (@records){
                
                my @fields = split(/\|/, $line);
                if ($args{part} eq $fields[0] && $args{rev} eq $fields[1]){
                        $retval = \@fields;
                        last;

                        close FH;
                        return \@fields;
                }
        }
        
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to