Think about Loose Coupling | |
PerlMonks |
Re: Should I use v5.10 because of named groups?by Fletch (Bishop) |
on Apr 13, 2021 at 22:36 UTC ( [id://11131229]=note: print w/replies, xml ) | Need Help?? |
First a syntax nit: personally I don't find that regex any more readable than:
In fact if you're explicitly wanting it in a hash I'd almost say go with something like this is still (IMHO) clearer:
Granted you're doing a minimal amount of validation checking [01] on the first two fields, but (without more context on your data) that doesn't feel that compelling. If you were to keep it with your regex with the capture groups then I'd at the least suggest adding an /x and putting whitespace around the colons so it's not as visually . . . run together. As to your question of using an explicit version: you can check the docs on feature what that turns on (specifically say, state, and the switch construct). Since named capture groups aren't toggled with that all you're getting is maybe bailing earlier in the (as you say) unlikely case you were ever run with an older perl. So . . . meh? That being said though I'm habitually using (say :) say and state so I typically use a much newer required version in what I write. Having that explicitly set regularly helps find problems (typically PATH is messed up and it's running under the ancient OS' /usr/bin/perl not the one it should be which would cause other things to blow up (missing CPAN modules etc.)).
The cake is a lie.
In Section
Seekers of Perl Wisdom
|
|