http://qs1969.pair.com?node_id=314886


in reply to Re: Re: Variable assignment confusion
in thread Variable assignment confusion

Please don't assume that someone else is right just because they are more experienced than you; always try (as you have done :) to get an explanation. Cargo cultism often stems from unquestioningly assuming that unusually-written code is that way for a reason.

As to your inquiry, '\z' matches the very end of the string; whereas '$' matches the end, or just before a newline at the end of a string.
This doesn't make any difference in your case; so I'd use '$' to avoid confusion.

If you're curious; '\z' becomes much more useful when you switch on the '/m' (multi-line) flag on a regex to allow '$' to match before any newlines in the string. Have a look at perldoc perlre or Mastering Regular Expressions for more details.