On Oct 5, Charles Farinella said:

Thank you for your help, with some help from someone in our office, here
is our solution, perhaps it will be helpful to someone else.

#!/usr/bin/perl -w

use strict;

my %hash;
my $sku;
my $verbose = 0;
my $numDuplicates = 0;

open( INFILE, 'stock.tab' );

You should make sure this succeeded, for debugging purposes:

  open INFILE, 'stock.tab' or die "can't read stock.tab: $!";

foreach( <INFILE> ) {

You'd be better off using a while loop, which reads one line at a time, instead of a for loop, which reads ALL the lines into memory at once!

  while (<INFILE>) {

And then you should chomp $_ before going further; otherwise, the last element of @array is going to have a newline at the end of it.

       my @array = split( "\t", $_ );

    chomp;
    my @array = split /\t/;  # $_ is assumed here

           $sku = $array[0];
           $hash{$sku}++;
            # test printout
           print "$sku [$hash{$sku}]\n" if $verbose;

You don't really need $sku here... but you can use it if you wish.

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to