开发者

Is there a way to determine exactly what operator a Perl B::LOGOP object refers to?

开发者 https://www.devze.com 2023-03-25 20:23 出处:网络
From playing with B, I see that a B:开发者_StackOverflow社区:LOGOP object (call it \"$op\") referring to either a && or and operator will both return \"and\" upon calling $op->name. Is it p

From playing with B, I see that a B:开发者_StackOverflow社区:LOGOP object (call it "$op") referring to either a && or and operator will both return "and" upon calling $op->name. Is it possible to determine which operator the LOGOP refers to merely by examining $op?


I am not expert for perl internals, but LOGOP refers to logical operator group. So I don't think you can know individual operator without examining the name. Even B::Terse displays it:

perl -MO=Terse -e '$a && $b'

Shows:

....
        LOGOP (0x198ad94) and
            UNOP (0x198adec) null [15]
                PADOP (0x198ae08) gvsv  GV (0x187bb9c) *a
            UNOP (0x198adb4) null [15]
                PADOP (0x198add0) gvsv  GV (0x187bc9c) *b
0

精彩评论

暂无评论...
验证码 换一张
取 消