You could try it like this:

#!/usr/bin/perl use warnings; use strict; my $employee_file = 'employee_list.csv'; open OUTFILE, '>', 'test.script' or die "Cannot open 'test.script' $!" +; my $employee_name; if ( @ARGV == 1 ) { $employee_name = $ARGV[ 0 ]; } else { print "\n\nPlease enter the employee's name: "; chomp( $employee_name = <STDIN> ); while ( 1 ) { print "\n\nYou entered $employee_name - is this correct? <y or + n>:"; my $ans = lc substr <STDIN>, 0, 1; if ( $ans eq 'n' ) { print "\n\nPlease enter the server name: "; chomp( $employee_name = <STDIN> ); next; } elsif ( $ans eq 'y' ) { last; } } } my @name_breakdown = split ' ', $employee_name; open my $EFH, '<', $employee_file or die "Cannot open '$employee_file' + $!"; while ( <$EFH> ) { my $field = ( split /:/ )[ 1 ]; push @exact_check, $field if length $field and /\Q$employee_name/ +; push @approx_check, $field if length $field and /\Q$name_breakdown +[1]/ and /\Q$name_breakdown[0]/; } close $EFH; print "EXACT MATCHES:\n", '=' x 50, "\n"; my $key = 'a'; my %lookup; for my $check ( @exact_check ) { $lookup{ $key } = $check; print $key++, ". $check\n"; } print "\n\nAPPROXIMATE MATCHES:\n", '=' x 50, "\n"; for my $check ( @approx_check ) { $lookup{ $key } = $check; print $key++, ". $check\n"; } print "Please select which is correct: "; my $ans = lc substr <STDIN>, 0, 1; if ( exists $lookup{ $ans } ) { my @breakdown = split /,/, $lookup{ $ans }; splice @breakdown, 1, 0, $ans eq 'a' ? 'TESTING' : 'THINGS'; print OUTFILE join ',', @breakdown; } __END__

In reply to Re: Better Way to Search Large File. by jwkrahn
in thread Better Way to Search Large File. by walkingthecow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.