in reply to Strange syntax question

So, to translate the operational effect, the original author of that line of code seems to be using that one-liner to establish a default value for the parameter to Doit() in the event it is called without a parameter. Furthermore, maintenance of that default value is moved to the top of the source file for easy modification.

Nice trick. I think I'll be taking that one home today.

Replies are listed 'Best First'.
Re^2: Strange syntax question
by AnomalousMonk (Archbishop) on Aug 14, 2013 at 23:44 UTC

    Take it home and use it, certainly, but don't leave that loaded global variable lying around where it can hurt someone!

    >perl -wMstrict -le "use constant FOO => 'bar'; ;; DoIt(); ;; sub DoIt { my $it = shift // FOO; print qq{it is '$it'}; } " it is 'bar'