sub mycode { (my $var = $_[0]); (defined($var) ? print("mycode() called with $var\n") : print("mycode() called with no operands.\n")); ($var and (my $foo = 'blah')); #^^^^^^^^^^^^^^^ Look here ($foo and print("foo is $foo\n")); ($foo ||= 'FOO'); } mycode('test'); mycode(); mycode(); mycode(); a.pl syntax OK