in reply to Re^2: Matching ranges
in thread Matching ranges
Data Used:#!/usr/bin/perl -w use strict; my $num =1; while(<DATA>) { if ( (/^Services\s*$/../^Users\s*$/) =~ /^(\d+)(?<!^1)$/ ) { last if $1 <= $num++; #only first Services section next if /^====/ || /^\s*$/; #if you don't want these print "$_"; } } =prints blah glah sfsd asfsdf afsafdf =cut
__DATA__ ======================================================== Net Stuff ======================================================== slfjs sfafdds aslfkjsdl sfsdf ======================================================== Services ======================================================== blah glah sfsd asfsdf afsafdf ======================================================== Users ======================================================== Services sam bill frank
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Matching ranges
by ldbpm (Initiate) on Sep 02, 2010 at 15:12 UTC |