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

Finding the *correct* line number

Thread Next
From:
Ovid
Date:
September 28, 2006 18:10
Subject:
Finding the *correct* line number
Message ID:
20060928134332.2125.qmail@web60815.mail.yahoo.com
I think I asked this before, but I can't recall.  Sorry if this is a dup.

There's a known bug in caller:

    #!/usr/bin/perl -l

    my @results = (qw<caller sucks>);
    while ( my $answer = get_result() ) {
        print $answer;
    }

    sub get_result {
        my ( $package, $file, $lineno ) = caller;
        print $lineno;
        return shift @results;
    }

That prints:

    4
    caller
    5
    sucks
    5

Is there anyway I can get the correct line number?  A better solution for my problem would be solving this:

  while ( my ($this, $that) = (get_result(), get_result()) ) {
      ....
  }

What I really need to know, from the perspective of get_result(), is to uniquely identify *which* get_result() call was made.  I'm guessing there's something deep in the B modules which would do this, but I'm not sure.

Any ideas?

Cheers,
Ovid
 
-- 
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/




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