limartin has asked for the wisdom of the Perl Monks concerning the following question:

Does perl have equivalents of this C macros?
__FILE__
__LINE__

???? Thanks

Replies are listed 'Best First'.
Re: Equivalent of C
by dpuu (Chaplain) on Aug 24, 2004 at 00:39 UTC
    If you were to try using them, you'd quickly find that the answer is "yes" (and there's also __PACKAGE__). More generally, you can use caller to inspect the files/functions in your call stack.

    --Dave
    Opinions my own; statements of fact may be in error.
Re: Equivalent of C
by Zaxo (Archbishop) on Aug 24, 2004 at 00:41 UTC

    Yes, they're called __FILE__ and __LINE__. See also the #line directive, which lets you reset them at whim.

    After Compline,
    Zaxo

Re: Equivalent of C
by bart (Canon) on Aug 24, 2004 at 12:11 UTC
    Documented in perldata, somewhere under "Scalar value constructors":

    The special literals __FILE__, __LINE__, and __PACKAGE__ represent the current filename, line number, and package name at that point in your program. They may be used only as separate tokens; they will not be interpolated into strings. If there is no current package (due to an empty package; directive), __PACKAGE__ is the undefined value.