I was going to look into this, but i absolutely hate, hate implicit the use of $_. It makes the code so much harder to read and so much harder to understand and so much harder to follow. I prefer it more like this:
#!usr/bin/perl use strict; use warnings; open my $wave, '>', 'Wave' or die "Can't open $wave: $!"; open my $keywords, '<', 'Agents' or die "Can't open keywords: $!"; open my $search_file, '<', 'Definitions' or die "Can't open search f +ile: $!"; # Urgh, that following line needs serious reformatting, # It's still an ugly mess that is very hard to understand at a glance my $keyword_or = join '|', map {chomp;qr/\Q$_\E/} <$keywords>; my $regex = qr|\b($keyword_or)\b|; while((my $line = <$search_file>)) { if($line =~ /$regex/g) { if ( $line =~ /(SCRIPTNAME|DESCRIPTION)/ ) { next; } print $wave $line; } } close $wave; close $keywords; close $search_file;
Still less the ideal, but at least i could start to follow the data around.
In reply to Re: nesting loops help?
by cavac
in thread nesting loops help?
by shadowfox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |