in reply to Text matching repost
Glad I've finally found a useful non-numeric-iterating purpose for .. :)#!/usr/bin/perl use strict; use warnings; my ($start, $stop) = (qr '#ifdef|#if defined', qr '#endif'); open INPUT, '<', 'monks23.dat' or die "Error opening input: " . $!; while (<INPUT>) { if (/$start/ .. /$stop/) { # Print the lines themselves if (/$start/ or /$stop/) { print; } # Skip the rest next; } print; } close INPUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text matching repost
by Neighbour (Friar) on Jun 18, 2012 at 12:19 UTC | |
by afoken (Chancellor) on Jun 18, 2012 at 14:24 UTC | |
by Neighbour (Friar) on Jun 19, 2012 at 06:39 UTC | |
|
Re^2: Text matching repost
by prassi (Acolyte) on Jun 18, 2012 at 10:45 UTC | |
by Neighbour (Friar) on Jun 18, 2012 at 11:09 UTC |