batcater98 has asked for the wisdom of the Perl Monks concerning the following question:
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.$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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: If Exists in an Array?
by keszler (Priest) on Nov 12, 2009 at 23:03 UTC | |
|
Re: If Exists in an Array?
by bichonfrise74 (Vicar) on Nov 12, 2009 at 23:07 UTC | |
by 7stud (Deacon) on Nov 13, 2009 at 10:16 UTC | |
by keszler (Priest) on Nov 13, 2009 at 13:43 UTC | |
by 7stud (Deacon) on Nov 13, 2009 at 10:21 UTC | |
by batcater98 (Acolyte) on Nov 13, 2009 at 14:44 UTC | |
by keszler (Priest) on Nov 13, 2009 at 17:10 UTC |