http://www.perlmonks.org?node_id=1045456


in reply to extract line

I made a hash containing all of the part numbers of interest (file 1) then I read through file 2 and printed any lines that have a part number that exists in the hash of part numbers:
#!/usr/bin/env perl use strict; use warnings; my %part_nums = map { $_ => 1 } qw(3478749 3633731); while ( my $line = <DATA> ) { my ($part) = split /:/, $line; print $line if exists $part_nums{$part}; } __DATA__ 3478748:AA:1D:AAA:Descriptions:C:2 3478749:AA:1D:AAA:Descriptions:C:2 3633731:AA:3E:AAA:Descriptions:C:2

OUTPUT:

3478749:AA:1D:AAA:Descriptions:C:2 3633731:AA:3E:AAA:Descriptions:C:2