I like to use several regexes ... if you want the string at the end, $
will anchor to the end-of-string. If you can't easily say it in one regex, use several. If split()
seems natural, just do it, then pop
the result off the end. In the long run it probably will not make the slightest bit of difference which way you do it, as long as it can be proved to work correctly with all possible inputs that it will encounter and if it is abundantly clear to the human eye. (Literally... use Test::Most
to construct a thorough test-case which will prove that the parsing algorithm you selected will always accept valid strings and will always reject invalid ones.