http://www.perlmonks.org?node_id=495983


in reply to Re^4: Have you netted a Perl Monk or Perl Pretender in 5 minutes or less?
in thread Have you netted a Perl Monk or Perl Pretender in 5 minutes or less?

It tests the candidate's understanding of Perl syntax. To understand that line you must know the effects of using unless (and if I'm asking the questions that will quickly turn into what Perl considers true and false values) as well as execution order in a statement. Put concicely, it says that if $c exists and is true maintain it's value, otherwise set it to 1. It is an occasionally useful construct for fixing user input errors and the like.

I did notice that the way you've got it written it is a trick question - if you set the original value of $c to be 0 or "" the "my" would produce a warning about re-declaring a variable that was declared in the same scope.