Jerry Kassebaum wrote:
> Friends,
>
> Below is a portion of code which repeats $v ad infinitum when the if
> condition is met. How do I break out of the loop?
>
> foreach $v (keys %sym) {
> if($sym{$v}>1) {
> print $v; <>; # Here's where it repeats the same thing, rather than
> advancing.
> }
> }
What's the <>; doing in there ? It could lock you up waiting input.
Where's your newline on the print ?
What does it repeat ?
Run this first - then modify to suit:
use strict;
use warnings;
my %sym = (a => 1, b => 2, c => 3);
foreach my $v (keys %sym) {
if ($sym{$v} > 1) {
print "$v => $sym{$v}\n";
}
}
__END__
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs