Let's assume you've read these lines in one at a time into $_, using something like this:
open my $file, "<", "my.file" or die "Can't open my file: $!"; while(<$file>) { # $_ has the current line print if /tts\s0./; print if /[tts30]/; print if /^[23]/; }
The first pattern would not print anything, because it's looking for "tts", one whitespace character immediately after the "tts" (with no intervening characters), then a zero, then any one character other than a newline.

The second would print the first and last lines, because it's looking to find one copy of either t, s, 3, or 0, anywhere in the line.

The last one would print nothing, because it wants either a 2 or 3 at the beginning (the '^') of the line.

You can try things like this in the debugger by starting it up with perl -demo, setting $_ to the line you want to match against, and then entering the print if lines, changing $_ to try the different data lines.


In reply to Re: Stupid question by pemungkah
in thread Matching Operators by rolandomantilla

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.