I think what diotalevi is trying to acheive is the reverse of B's next method
Er, no. Siblings and next are two different things. Siblings are a chain of ops at the same level in a tree; next is the next op in execution sequence. For example
$ perl584 -MO=Concise -e'print "a", $b+1;' 9 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 8 <@> print vK ->9 3 <0> pushmark s ->4 4 <$> const(PV "a") s ->5 7 <2> add[t1] sK/2 ->8 - <1> ex-rv2sv sK/1 ->6 5 <$> gvsv(*b) s ->6 6 <$> const(IV 1) s ->7 $ perl584 -MO=Concise,-exec -e'print "a", $b+1;' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v 3 <0> pushmark s 4 <$> const(PV "a") s 5 <$> gvsv(*b) s 6 <$> const(IV 1) s 7 <2> add[t1] sK/2 8 <@> print vK 9 <@> leave[1 ref] vKP/REFC
Here, the first child of print is pushmark, and const and add are the two siblings of pushmark. On the other hand, print's next op is leave.

Internally Perl doesn't store pointers to previous siblings, not does it store a pointer to the parent. So my initial reaction is that the OP's approach is correct. However, since the B modules provide a parent() method when internally there is no such pointer, it's posssible that B:;* can do other clever stuff too. I've never looked at it myself.

Dave.


In reply to Re^2: Find opcode's reverse sibling? by dave_the_m
in thread Find opcode's reverse sibling? by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.