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.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 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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |