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

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

Thread Previous | Thread Next
From:
rgarciasuarez
Date:
September 21, 2001 02:30
Subject:
Re: do{die} vs. do{ die}
Message ID:
slrn9qm26i.h6b.rgarciasuarez@rafael.kazibao.net
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About