Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: nesting loops help?

by BillKSmith (Monsignor)
on Mar 09, 2022 at 18:50 UTC ( [id://11141960]=note: print w/replies, xml ) Need Help??


in reply to nesting loops help?

No nested loops are required. Create a hash whose keys are the lines of 'schedule' and whose values indicate whether or not the corresponding line exists in $wave. (untested:)
use strict; use warnings; use autodie; open my $schedule, '<', 'schedule_file.txt'; my %schedule; $schedule{$_} = 1 while (<$schedule>); close $schedule; open my $search, '<', 'search_file.txt'; my %search; $search{$_} = exists $schedule{$_} while (<$search>); close $search; my @yes = ('','yes'); my $regex = qr/tbsl/; open my $keywrds, '<', 'keywrds.txt'; open my $wave, '>', 'wavefile.txt'; while (<$keywrds>) { if (exists($search{$_}) and (/$regex/) ) { print $wave $_, ' ', $yes[$search{$_}], "\n"; } } close $wave; close $keywrds;
Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-29 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found