P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As others already said, no. Here's what the compiler backend B (B::Terse) says, running
substituting the addresses with 0x? and running 'vimdiff for while': ==================== for ====================|=================== while =================== LISTOP (0x?) leave [1] | LISTOP (0x?) leave [1] OP (0x?) enter | OP (0x?) enter COP (0x?) nextstate | COP (0x?) nextstate BINOP (0x?) leaveloop | BINOP (0x?) leaveloop LOOP (0x?) enteriter | LOOP (0x?) enterloop OP (0x?) null [3] | --------------------------------------------- UNOP (0x?) null [147] | --------------------------------------------- OP (0x?) pushmark | --------------------------------------------- UNOP (0x?) readline [2] | --------------------------------------------- PADOP (0x?) gv GV (0x?) *ARGV | --------------------------------------------- PADOP (0x?) gv GV (0x?) *_ | --------------------------------------------- UNOP (0x?) null | UNOP (0x?) null LOGOP (0x?) and | LOGOP (0x?) and OP (0x?) iter | UNOP (0x?) defined ---------------------------------------------| UNOP (0x?) null ---------------------------------------------| UNOP (0x?) null [15] ---------------------------------------------| PADOP (0x?) gvsv GV (0x?) *_ ---------------------------------------------| UNOP (0x?) readline [2] ---------------------------------------------| PADOP (0x?) gv GV (0x?) *ARGV LISTOP (0x?) lineseq | LISTOP (0x?) lineseq COP (0x?) nextstate | COP (0x?) nextstate LISTOP (0x?) print | LISTOP (0x?) print OP (0x?) pushmark | OP (0x?) pushmark UNOP (0x?) null [15] | UNOP (0x?) null [15] PADOP (0x?) gvsv GV (0x?) *_ | PADOP (0x?) gvsv GV (0x?) *_ OP (0x?) unstack | OP (0x?) unstack which shows,that for gobbles up all lines (LOOP enteriter) to process each (OP iter) after that, whereas the while loop (LOOP enterloop) processes readline and print in the loop body (LOOP enterloop).
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
In reply to Re: Internally, how do for() and while() differ?
by shmem
|
|