in reply to Re: line number
in thread line number

wow......3 solid responses in like 1 minute. Thanks.

Replies are listed 'Best First'.
Re: Re: Re: line number
by Anonymous Monk on Mar 01, 2004 at 20:45 UTC
    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.
      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

      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

      That's what Carp is all about. It combines __LINE__ with caller magic to provide a stacktrace (similar is Devel::StackTrace)