I used Inline::Files so that I could produce a single post with runnable Perl code.

You can do that without a module by open'ing a reference to a HEREDOC. That would work for multiple input "files" as in your mentioned solution.

use strict; use warnings; use Data::Dumper; open my $inFH, q{<}, \ <<EOD or die qq{open: < HEREDOC: $!\n}; COA213345 COA213345 COA213445 DOB213345 EOA213345 EOD my %lookup = map { chomp; $_ => 1 } <$inFH>; close $inFH or die qq{close: < HEREDOC: $!\n}; print Data::Dumper->Dumpxs( [ \ %lookup ], [ qw{ *lookup } ] );

The output.

%lookup = ( 'EOA213345' => 1, 'COA213445' => 1, 'COA213345' => 1, 'DOB213345' => 1 );

For the purposes of the OP's request, note that using a hash removes the duplicate value in the input.

Cheers,

JohnGG


In reply to Re^2: Load a single column file into a hash by johngg
in thread Load a single column file into a hash by vighneshmufc

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.