You may want to experiment with the flip/flop operator "..". It basically does the work of your $in_combat logic. It takes a little while to get used to, but it certainly makes the code a bit simpler once you're used to it:
$ cat krunk.pl #!/usr/bin/perl # # Demo for flip-flop operator # use 5.14.0; use warnings; use autodie; while (<DATA>) { if (/start/ .. /stop/) { # in combat! print "COMBAT: $_"; } } __DATA__ soon the combat will begin start combat! Biff! Pow! Bam! (Looks like Batman!) stop combat fight had three superlatives $ perl krunk.pl COMBAT: start combat! COMBAT: Biff! Pow! Bam! COMBAT: (Looks like Batman!) COMBAT: stop combat
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re^2: Split files based on regexp
by roboticus
in thread Split files based on regexp
by TonySoprano
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |