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


in reply to Re: Can you guess the result? Is it a bug?
in thread Can you guess the result? Is it a bug?

Because $test is in double-quotes, your shell is trying to interpolate it. Since it isn't set though (and there aren't such things as warnings and strict for the shell ; ), it is replaced with nothing and becomes:
perl -wMstrict -e"if( my() = 0 ) { print 'Passed'; } else { print 'Fai +led'; }"
If you escape the $ you'll be fine.
perl -wMstrict -e"if( my(\$test) = 0 ) { print 'Passed'; } else { prin +t 'Failed'; }"

Replies are listed 'Best First'.
Re: Re: Re: Can you guess the result? Is it a bug?
by Cine (Friar) on Jul 31, 2003 at 13:31 UTC
    A better way is to make sure the shell doesnt even try...
    perl -wMstrict -e'if( my() = 0 ) { print "Passed"; } else { print "Failed"; }'

    T I M T O W T D I