hello and welcome to the monastery and to the wonderful world of Perl
Daikini
the name of what you are looking for is strange: the flip flop operator.
A more serious description is 'bistable operator'. it is described in docs in the
Range Operators.
The normal usage looks like:
while (<FH>) { print if $_ =~ /start/../end/ }
ie, as you can see it evaluates true (and in the example above it print because it evaluate true) only since 'start' is matched. It evaluates true until 'end' is matched, after 'end' is matched it evaluetes false.
Please note that for our convenience and hystorical reasons (?) if either opernads of flip-flop
.. operator is constant it is considerd true if equal the current line number
$. so if you write:
if (101 .. 200) { print; }
means:
if ($. == 101 .. $. == 200) { print; }
Or, in words: 'print only line from 101 to 200'.
Have also a read of
Flipin good, or a total flop? and
flip-flop interpolationHtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.