Re: perl deparse question.




ewaguespack@xxxxxxxxx wrote:
What does the -p do in the following line:

perl -MO=Deparse,-p



http://search.cpan.org/~nwclark/perl-5.8.8/ext/B/B/Deparse.pm

-p
Print extra parentheses. Without this option, B::Deparse includes
parentheses in its output only when they are needed, based on the
structure of your program. With -p, it uses parentheses (almost)
whenever they would be legal. This can be useful if you are used to
LISP, or if you want to see how perl parses your input. If you say

if ($var & 0x7f == 65) {print "Gimme an A!"}
print ($which ? $a : $b), "\n";
$name = $ENV{USER} or "Bob";
B::Deparse,-p will print

if (($var & 0)) {
print('Gimme an A!')
};
(print(($which ? $a : $b)), '???');
(($name = $ENV{'USER'}) or '???')
which probably isn't what you intended (the '???' is a sign that perl
optimized away a constant value).

.



Relevant Pages

  • Re: How to extract certain part of an regexp?
    ... I read some more document about Perl one hour ago. ... parentheses) to using the printfunction ... Terms and List Operators (Leftward) ... exit); # Obviously not what you want. ...
    (comp.unix.shell)
  • Re: about matching in a list context
    ... I don't understand this behavior of perl: ... If the /g option is not used, m// in list context returns a list ... consisting of the subexpressions matched by the parentheses in the ... (Remember that the foreach modifier, like the foreach loop, imposes list ...
    (comp.lang.perl.misc)
  • Re: Using Subroutines with CGI::Session::MySQL?
    ... Leave off the parentheses. ... The ampersand is the old way of calling Perl subs. ... L. D. James ...
    (comp.lang.perl.misc)
  • Re: foreach statements parentheses
    ... >> without needing the parentheses. ... > a list constructor in Perl. ... > assignment is determined by the *left* side of the assignment. ... parens on the left side *do* force list context. ...
    (comp.lang.perl.misc)
  • Re: newbie pattern match question :-)
    ... storing said string in a variable. ... The '*' symbol is a quantifier in a Perl regular expression, ... you need to insert that character class. ... You need parentheses to make the regex capture the desired string. ...
    (comp.lang.perl.misc)