Thanks for your help, Bill! I ran your code, which worked, which made me
take a different look at my code.
Sorry, but I didn't give you enough info to spot the problem. Here's the
whole thing:
################
open(STORAGE, "<gutter.txt");
while(<STORAGE>) {
$_ =~ /(\w+)/;
$sym{$1}++;
foreach $v (keys %sym) {
if($sym{$v}>1) {
print $v; <>;
}
}
}
close STORAGE;
print "That's it."; <>;
###################
I'm checking gutter.txt for duplicates. Each line is a word followed by
info. I want to make sure that first word is never repeated.
The problem is the final closing bracket. Put it before the foreach line and
it all works as intended.
I was thinking I needed a "next" or "last" or "break" or something. Your
code showed me that wasn't the problem. Thanks!
>What's the <>; doing in there ?
I don't like to open a DOS window if I don't have to. "<>;" is a debugging
tool. When I double-click on file.pl, the DOS output window will stay open
waiting for me to hit <enter>. After I hit the final <enter>, it closes.
When I'm done testing, I take them out.
>Where's your newline on the print ?
That's another side-effect of "<>;".
>What does it repeat ?
Heh, you're still making me think! It wasn't an infinite loop afterall.
Here's enough data for gutter.txt to give you the idea.
###
%%AMAT**Tue Sep 5 07:07:15 2006
%%BCE**Tue Sep 5 07:07:15 2006
%%AMAT**Tue Sep 5 07:07:15 2006
%%BRLI**Tue Sep 5 07:07:16 2006
%%BNK**Tue Sep 5 07:07:16 2006
###
My original text has a lot more lines. It only repeats once per line, due to
the "while". I never pressed <enter> enough to get to the end, so I assumed
infinity. Oops.
I hope that wasn't too boring. I thought I owed you an answer to your
questions, and an apology for not giving you enough info the first time.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs