SPUG: Behavior of &&'ed functions (B::Deparse and perltidy)
David Dyck
david.dyck at fluke.com
Wed Oct 27 18:48:33 CDT 2004
On Wed, 27 Oct 2004 at 13:20 -0700, John Costello <cos at indeterminate.net> wrote:
> Why does Perl (5.8.0) behave this way?
Don't you just had it when you start composing email
and forget to send it till it's too late :-)
I see you were already given a response, but I
want to follow up with a plug for 2 perl tools
that can help you understand what "perl is thinking"
I took your code perl6.pl and used Deparse to explain
how perl parses the code
perl -MO=Deparse,-p test6.pl > test6p.pl
See perldoc B::Deparse for an explanation...
When you use the -p option, the output also includes parentheses even
when they are not required by precedence, which can make it easy to
see if perl is parsing your expressions the way you intended.
Then I asked perltidy to pretty print the coutput
# see http://perltidy.sourceforge.net
perltidy test6p.pl
cat test6p.pl.tdy
use strict 'refs';
my ($column);
( $column = 0 );
print(
(
( "column is: $column\n" && ( ++$column ) )
&& print("now column is: $column\n")
)
);
print(
(
( "and column is: $column\n" && ( $column++ ) )
&& print("and now column is: $column\n")
)
);
More information about the spug-list
mailing list