I have a very large file that I am parsing through as in my last post - Thank you for the help!! Now I am trying to use a list of items in an array - parse though the large file pulling out a field and checking to see if it is in the array - if so increment a count to get a record count. I don't think my lookup in the arrary is working.
$logfile="d:\\ScanReps\\TR&D\\WDL_Scan_0000.csv"; $locofile = "d:\\ScanReps\\TR&D\\locos.txt"; open(DAT, $logfile); open(loco, $locofile); %loco_data = <loco>; close(loco); $linecnt1 = 0; $linecnt2 = 0; while ($record = <DAT>) { chop($locodn); ($RR_Name,$Loco_no,$Event_Date,$Event_Time,$Event_Code,$Event_Durati +on,$Source_File)=split(/,/,$record); chop($loco_data); chop($Loco_no); if (exists($loco_data{$Loco_no})) { $linecnt1 = $linecnt1 +1; } $linecnt2 = $linecnt2 + 1; print "Rec: ",$linecnt2, " In: ",$linecnt1, "\r"; } close(DAT);
The locos.txt is just a list of numbers - one number per line - I want to compare the value pulled in to $loco_no to the values in the array and if there inc the counter. Thanks, Ad.

In reply to If Exists in an Array? by batcater98

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.