in reply to Re^3: How do I display only matches (updated)
in thread (SOLVED) How do I display only matches
Correct, in this case it doesn't matter. However since print can take an optional file handle print $fh $data there are some cases where print can be confused about what the first token means (filehandle or something to print to a filehandle). I coded what I knew would work rather than the minimal formulation. I didn't take any time worrying about this detail. My main point as you observed was: "make the regex as complicated as it needs to be, but no more"!
I will point out that the Regex character "$" solves the platform specific line ending \r\n vs \n vs no line ending problem. "$" matches the the end of the string (or before newline at the end of the string; or before any newline if /m is used). I think \Z is the same. So /abc$/ matches lines ending in abc whether there is a line ending there or not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How do I display only matches
by haukex (Archbishop) on Sep 25, 2019 at 17:20 UTC | |
by Marshall (Canon) on Sep 25, 2019 at 20:28 UTC | |
by haukex (Archbishop) on Sep 25, 2019 at 21:20 UTC | |
by Marshall (Canon) on Sep 25, 2019 at 21:58 UTC | |
by haukex (Archbishop) on Sep 25, 2019 at 22:08 UTC | |
| |
by haukex (Archbishop) on Sep 25, 2019 at 21:52 UTC | |
by jcb (Parson) on Sep 26, 2019 at 01:13 UTC | |
by haukex (Archbishop) on Sep 26, 2019 at 05:50 UTC | |
by Marshall (Canon) on Sep 26, 2019 at 04:05 UTC | |
by haukex (Archbishop) on Sep 26, 2019 at 05:47 UTC | |
| |
by jcb (Parson) on Sep 26, 2019 at 22:46 UTC | |
|