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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: A F***ing bug in caller()
by Elian (Parson) on Dec 04, 2002 at 15:15 UTC
    This isn't a bug--you're using the #line directive, so perl's doing what you asked it to, whether you knew you were or not.

    The format's more or less:

    /^#\s*line\s+(\d+)(.*)/
    where $1 becomes the new line number and $2 the new file name.

    Not often used, but it's not a bug. (Though arguably there should've had to have been a space between the number and the name)

Re: A F***ing bug in caller()
by BrowserUk (Patriarch) on Dec 04, 2002 at 15:15 UTC

    I think what you discovered is a feature, not a bug.

    From the first paragraph of the last section of perlsyn

    Plain Old Comments (Not!) Much like the C preprocessor, Perl can process line directives. Using +this, one can control Perl's idea of filenames and line numbers in er +ror or warning messages (especially for strings that are processed wi +th eval()). The syntax for this mechanism is the same as for most C p +reprocessors: it matches the regular expression / ^#\s*line\s+(\d+)\s +*(?:\s"([^"]+)")?\s*$/ with $1 being the line number for the next lin +e, and $2 being the optional filename (specified within quotes).

    I think the answer to your problem is, if you don't mean to do that, "Don't write lines like that!" :^)


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

Re: A F***ing bug in caller()
by RMGir (Prior) on Dec 04, 2002 at 15:28 UTC
    First, note that D::T on CPAN is version 0.10, and it dates back to 1999. I'd relax and take a deep breath before getting profane about something that beta and that old... :)

    Well, ok, you seem to be getting profane about caller, not D::T. That brings us to:

    Second, you've found a feature, not a bug. Your # line 2bug comment is acting like a #line directive in C or C++ would. I didn't know perl supports line directives, but that doesn't surprise me. In fact, this is documented in perlsyn, at least for my 5.6.1 installation. Look at the bottom of the file.
    --
    Mike

      Well, I have to take my words back.
      I believe this feature can be useful for some cases, but I believe a more unique string should have been used.
      From the doc it seems like an ancient feature, so I believe this gives the answer.

      Thanks everybody, it is good to know there is some place you can get answers.
      shushu