Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Next from inner loop only works "most of the time"

by GrandFather (Saint)
on May 20, 2021 at 11:51 UTC ( [id://11132773]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Next from inner loop only works "most of the time"
in thread Next from inner loop only works "most of the time"

I crunched your code down a little to turn it into a test script. You may like to try running it to see if it reproduces the issue. If it doesn't you could try adding back elements of your script until you get back to a UFO. At that point you will have identified a critical component (whatever you added last) and that may help us figure out where the issue is.

use strict; use warnings; print "Starting\n"; for (1 .. 100000) { my @results = draw(); print "@results\n" if 2 != @results; } print "Done\n"; sub draw { my @dic = ('thew', 'trow', 'whew'); my %master_letter_freq; my $master_letter_list = 'otrwreh'; my $regex = ''; ++$master_letter_freq{$_} for split //, $master_letter_list; for (split //, '---w') { $regex .= $_ eq '-' ? "[$master_letter_list]" : $_; } my @result = grep {/^$regex$/i} @dic; my @results; RESULT: foreach (@result) { my %seen; $seen{$_}++ for (split //, lc $_); foreach (keys %seen) { next RESULT if ($seen{$_} > $master_letter_freq{$_}); } push @results, $_; } return @results; }

On my machine running Perl 3.30.1 prints:

Starting Done
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132773]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found