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

Re: Ternary Operator: Condition-Negation

by theorbtwo (Prior)
on Aug 28, 2002 at 09:15 UTC ( [id://193394]=note: print w/replies, xml ) Need Help??


in reply to Ternary Operator: Condition-Negation

You have indeed, as dws explained so well. A nice tool for situations like these, where you suspect perl might parse your code differently then you want it to, is B::Deparse, which shows you exactly what perl thinks your code is saying. In this case, using it looks somthing like this:

C:\WINDOWS\Desktop>perl -c -MO=Deparse,-p -e "$history{$_} ? splice(@h +istory,$i--,1) : $history{$_}=1;" Can't modify splice in scalar assignment at -e line 1, near "1;" -e had compilation errors. (($history{$_} ? splice(@history, ($i--), 1) : $history{$_}) = 1);

In this case, I want perl to try to compile without running (-c), using the O module (the compiler-front end; for technical reasons (read: reasons I don't recall) Deparse is considered a compiler), passing it the Deparse (tells it to use B::Deparse, and pass it the rest as parameters), and -p (tells deparse to give me lots of parenthesies). For more info on using B::Deparse, follow any of those links; there's also options to not munge various things to give you a look that's closer to perl's, but harder to read.

Deparse is very useful for deobfuscating obfuscations, both intentional and otherwise. Oh, and it's core in 5.6 and later, IIRC. (For some reason, the CPAN results disagree with me, and say 5.8, which can't be right, since I have it and am on 5.6. Strange...)


Confession: It does an Immortal Body good.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://193394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-29 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found