Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: The Behavior of 'do'

by PrakashK (Pilgrim)
on Jul 26, 2001 at 23:00 UTC ( #100090=note: print w/replies, xml ) Need Help??

in reply to The Behavior of 'do'

I am not well versed with the way perl parser works. But I took the help of Deparse backend and this is what it revealed.
>> perl -MO=Deparse -e 'do ("print")' do 'print'; -e syntax OK >> perl -MO=Deparse -e 'do (print)' do print($_); -e syntax OK >> perl -MO=Deparse -e 'do print' do 'print'; -e syntax OK >> perl -MO=Deparse -e 'do{print}' print $_;; -e syntax OK
do expects a BLOCK, SUBROUTINE (deprecated) or an EXPR as its argument. So, I am guessing that, when a BLOCK or SUBROUTINE is not passed, it is looking for an expression and probably allowing barewords.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://100090]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2018-01-18 06:24 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (206 votes). Check out past polls.