in reply to How to distinct the call position of a sub?

Wrong question. The better question is "How should I format the following so it is readable, maintainable, oh, and so caller tells me which iter is being called?". Phrased like that the answer is obvious:

while (my $x = iter (1, 10)) { while (my $y = iter (1, 10)) { print "$x$y" } }

with the bonus that it is then easy to see that there was a missing ( for the second while expression.


Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^2: How to distinct the call position of a sub?
by BrowserUk (Patriarch) on Nov 24, 2008 at 21:59 UTC

    Here's another reason why that answer is more than a little trite. Every conditional within an if/elsif/else cascade is reported as being on the same line:

    C:\test>perl sub iter{ warn join '|', caller; return int rand 3 } for(1 .. 10) { if( iter() == 0 ) { print 'first'; } elsif( iter() == 1 ) { print 'second'; } else { print 'third'; } } ^Z main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. main|-|3 at - line 1. thirdthirdthirdthirdfirstthirdsecondthirdfirstthird

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.