Quoth pjf@perltraining.com.au (Paul Fenwick): > > Autodie can tell when an overriden readline has been called, since it uses > the replacement code. It could use Want (or similar) to check to see if > that's being called in a pure boolean context, since: > > use autodie; while (<>) { ... } > > becomes: > > while (&readline(STDIN)) { ... } > > If it's being called in a pure boolean context, then I have a candidate for > magical $_ setting. The real test then is whether we're in a while loop by > ourselves. Then I only need to worry about what happens if the caller is > using a lexical $_, and add some caching so we don't need to repeat the > whole check for every call to readline(). > > Is there really really no way of testing if we're being called as the sole > argument to while? Yes, but not from pure-Perl, since not even B provides access to the context stack. From XS it's relatively easy. BenThread Previous | Thread Next