develooper Front page | perl.perl5.porters | Postings from September 2001

Re: do{die} vs. do{ die}

Thread Previous | Thread Next
September 21, 2001 02:30
Re: do{die} vs. do{ die}
Message ID:
Barrie Slaymaker wrote in perl.perl5.porters:
} I've been trying to get decent line numbers out of perl in the middle of
} list expressions.  Here's an oddity I found, any clues as to why the
} space makes all the difference?
} $ perl -e "print
} >
} >
} >
} > do{die}"
} Died at -e line 1.
} $ perl -e "print
} >
} >
} >
} > do{ die}"
} Died at -e line 5.

Yes. The internal line number maintained by the tokenizer is incremented
when it skips whitespace. (Technically, S_incline() is called by
S_skipspace()). And, if I understand correctly, the line number
associated to the op corresponding to a statement is set when the parser
finishes reducing to the rule for this statement : here, when is reduces
"print" / "do{die}". I don't think it's worth fixing. In fact I can't
decide whether "line 5" or "line 1" is more correct.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About