On Jan 2, Paul Kraus said: >As you can see I am building a hash on the first pass. Then on the >second pass I am building a second hash but I am checking the first hash >to see if it had a count greater then two. I don't see any other way to >do this except two passes through the file. Correct me if I am wrong.
Watch me. :) >I am using a foreach loop because I just picked it. :) it situations >like this I never really saw a difference between while and foreach. Why >would I want to use a while loop instead? foreach (<FOO>) reads ALL the lines of <FOO> at once, and makes a big list. while (<FOO>) only reads one line at a time. >foreach (<PEL>){ > chomp; > @temp=split /,/,$_; > $_=~s/ //g foreach (@temp); > $dup{$temp[1]}++; >} > >#add item->vendor part numbers to hash if don't exist in dup hash >seek PEL, 0, 0; >foreach (<PEL>){ > chomp; > @temp=split /,/,$_; > $_=~s/ //g foreach (@temp); > $vend{$temp[1]}=$temp[0] unless ($dup{$temp[1]} > 1); >} while (<PEL>) { chomp; s/ +//g; my ($value, $field) = split /,/; $dup{$field}++; if ($dup{field} == 1) { $vend{$field} = $value } else { delete $vend{$field} } } That looks to me like it will work. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]