But here I just show one simple approach that is easy to debug. There are Lot's of ways to do what you need.
Update: I just assumed that the last line sequence was all one line as you had blank lines before other examples - maybe a bad assumption - bichonfrise74's code looks good to me also - there are many ways Rome here.
Update:#!/usr/bin/perl -w use strict; while (<DATA>) { next if /^\s*$/; #skip blank lines chomp; #optional as \n would get deleted anyway s/^.*?start\s+//; #remove start and all before s/end.*//; #remove end and all after print "$_\n"; } #prints: # asdasd asdasdasd asdasdas # as asdas dasdasdad asdasddas # asdsadsdasddasds sdasdas asdasdasdasd asdasdsa asdasd asdasdasd __DATA__ asdasd start asdasd asdasdasd asdasdas end asdasdas adasdas start as asdas dasdasdad asdasddas end qweqwe asdasd start asdsadsdasddasds sdasdas asdasdasdasd asdasdsa asdasd asd +asdasd end
sorry for goof, brain isn't working full speed today!
preserves start and end tokens.s/^.*?start/start/; s/end.*/end/;
In reply to Re: how to get context between two flag
by Marshall
in thread how to get context between two flag
by cxfcxf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |