in reply to Re: Re: line number
in thread line number

I just wanted to make a global debug function and incorporate as much possible as I'm writing a lexer/parser and I prefer to generate my own debugging information built into the code. I'm not sure why this was so hard to find but I'm guessing way more people care about knowing where they are in a file they are reading, then in their own code in the context of PERL. I think the __LINE__ should suffice....and I haven't checked into CARP yet but I do vaguely recall stact traces somehow being involved with that.

Replies are listed 'Best First'.
Re: Re: Re: Re: line number
by leira (Monk) on Mar 01, 2004 at 20:53 UTC
    I haven't checked into CARP yet but I do vaguely recall stact traces somehow being involved with that.

    Yes, you can get a stack backtrace with Carp::cluck.

    Linda

Re: Re: Re: Re: line number
by saintmike (Vicar) on Mar 01, 2004 at 21:46 UTC
    Just FYI, if you're looking for a mature logging system, there's one on CPAN called Log::Log4perl:
    use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( {level => $DEBUG, layout => "%F:%L: %m%n"}); DEBUG("My Message"); INFO("Another message");
    This will log the two messages with filename and line number included:
    ./test.pl:15: My Message ./test.pl:16: Another message
    And there's of course much, much more, as your requirements grow. If you're interested, check out the details on log4perl.sourceforge.net.

    -- saintmike

Re: Re: Re: Re: line number
by Anonymous Monk on Mar 01, 2004 at 20:52 UTC
    That's what Carp is all about. It combines __LINE__ with caller magic to provide a stacktrace (similar is Devel::StackTrace)