in reply to Re: extract line
in thread extract line

Not very familiar with argv. Where am I giving the program my file names? I am also printing to a outfile. I tried it as written and receive an uninitialized value $partNumbers but believe this is due to the filename.

Replies are listed 'Best First'.
Re^3: extract line
by mtmcc (Hermit) on Jul 20, 2013 at 23:23 UTC
    $ARGV[0] is the first argument on the command line (name of file with longer 'serial numbers'), and $ARGV[1] is the second argument on the command line (file containing the integers).

    To run it:  script.pl serialnumbers.txt integers.txt

    To print to a third file, add this somewhere before the second while loop:

    open (my $output, ">", 'nameOfOutputFile.txt');

    and change print STDERR to print $output.

    I hope that works!
      What does the line $partNumber{$_} = 1; d?

      It runs but the output is incorrect. When I print $partNumber{$_} I get 1, the values assigned instead of the part number

        It is used for populating the part numbers hash. The part number is the key and '1' is the associated value. The '1' doesn't matter. You just want to have a hash with part numbers as the unique keys of the hash since you can quickly and easily check to see if a key exists in a hash. For example:
        print "$key exists in hash" if exists $hash{$key};