Professional Web Applications Themes

eval and __LINE__ - PERL Beginners

Caveat: It's late and I'm tired and frustrated, i.e. I'm y. I want to have something like die, but for the web, so I want it to print out the error with a <br> at the end, etc. How the F### do I get __LINE__ to be evaluated, not where it is in the program file, but where the function is called? Another way of asking this is, how would I rewrite the die function in perl? TIA... Sleep now... -- Anything within a performance is significant, whether intentional or not. [url]http://www.hacksaw.org[/url] -- [url]http://www.privatecircus.com[/url] -- KB1FVD...

  1. #1

    Default eval and __LINE__

    Caveat: It's late and I'm tired and frustrated, i.e. I'm y.

    I want to have something like die, but for the web, so I want it to print out
    the error with a <br> at the end, etc.

    How the F### do I get __LINE__ to be evaluated, not where it is in the program
    file, but where the function is called?

    Another way of asking this is, how would I rewrite the die function in perl?

    TIA... Sleep now...
    --
    Anything within a performance is significant, whether intentional or not.
    [url]http://www.hacksaw.org[/url] -- [url]http://www.privatecircus.com[/url] -- KB1FVD


    Hacksaw Guest

  2. #2

    Default Re: eval and __LINE__

    ----- Original Message -----
    From: "Hacksaw" <hacksawhacksaw.org>
    To: <beginnersperl.org>
    Sent: Saturday, September 06, 2003 8:38 PM
    Subject: eval and __LINE__

    > Caveat: It's late and I'm tired and frustrated, i.e. I'm y.
    >
    > I want to have something like die, but for the web, so I want it to print
    out
    > the error with a <br> at the end, etc.
    >
    > How the F### do I get __LINE__ to be evaluated, not where it is in the
    program
    > file, but where the function is called?
    >
    > Another way of asking this is, how would I rewrite the die function in
    perl?
    >
    > TIA... Sleep now...
    Hi -

    1) use Carp; - it shows errors from the caller's
    perspective. Look at the docs, but you car use
    'carp' (warinig) or 'croak' (die).
    2) the perl built-in function 'caller' gives line and
    script name information for the caller, the caller's
    caller, etc. Check the docs to roll your own carp.
    3) Go to sleep.

    Aloha => Beau;


    Beau E. Cox Guest

  3. #3

    Default Re: eval and __LINE__

    >1) use Carp; - it shows errors from the caller's
    > perspective. Look at the docs, but you car use
    > 'carp' (warinig) or 'croak' (die).
    >2) the perl built-in function 'caller' gives line and
    > script name information for the caller, the caller's
    > caller, etc. Check the docs to roll your own carp.
    >3) Go to sleep.
    1) Nope, I looked there, in the end it uses die, which defeats the purpose.

    2) Caller! YES! YES! (weird that I didn't see it when I searched perlfunc.
    Errr... maybe not...)

    3) Thanks, pal! <ZZZ>


    --
    Things are not as bad as they seem.
    They are worse than that.
    They are also better than that.
    [url]http://www.hacksaw.org[/url] -- [url]http://www.privatecircus.com[/url] -- KB1FVD


    Hacksaw Guest

  4. #4

    Default Re: eval and __LINE__

    Hacksaw wrote:
    >
    > I want to have something like die, but for the web, so I want it
    > to print out the error with a <br> at the end, etc.
    >
    > How the F### do I get __LINE__ to be evaluated, not where it is in
    > the program file, but where the function is called?
    >
    > Another way of asking this is, how would I rewrite the die function
    > in Perl?
    >
    Not sure exactly what you need, but will

    use CGI::Carp 'fatalsToBrowser'

    do it for you?

    Rob



    Rob Dixon Guest

  5. #5

    Default Re: eval and __LINE__

    > use CGI::Carp 'fatalsToBrowser'

    Ooo, cool. Thanks. Wow, two useful answers. I like this list.


    --
    Commitments are to be honoured.
    [url]http://www.hacksaw.org[/url] -- [url]http://www.privatecircus.com[/url] -- KB1FVD


    Hacksaw Guest

  6. #6

    Default Re: eval and __LINE__

    >>>>> "Rob" == Rob Dixon <robdixon.port995.com> writes:

    Rob> use CGI::Carp 'fatalsToBrowser'

    Just remember NEVER to leave that on in production code. EVER.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz Guest

  7. #7

    Default Re: eval and __LINE__

    > Rob> use CGI::Carp 'fatalsToBrowser'
    >
    > Just remember NEVER to leave that on in production code. EVER.
    Okay, I'll bite. Why? Obviously it'd look bad, but your reaction seems
    stronger than that.
    --
    The creative impulse animates whatever instrument is placed at its disposal.
    [url]http://www.hacksaw.org[/url] -- [url]http://www.privatecircus.com[/url] -- KB1FVD


    Hacksaw Guest

  8. #8

    Default Re: eval and __LINE__

    >>>>> "Hacksaw" == Hacksaw <hacksawhacksaw.org> writes:

    Hacksaw> Okay, I'll bite. Why? Obviously it'd look bad, but your reaction seems
    Hacksaw> stronger than that.

    <http://www.stonehenge.com/merlyn/LinuxMag/col14.html>

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz Guest

Similar Threads

  1. eval vs. set?
    By Shawn Wilson in forum Macromedia Flash
    Replies: 1
    Last Post: January 5th, 06:42 PM
  2. eval'
    By Ankur Gupta in forum PHP Development
    Replies: 1
    Last Post: November 11th, 04:58 PM
  3. Help with eval()
    By Phil Powell in forum PHP Development
    Replies: 2
    Last Post: October 10th, 10:19 AM
  4. Counterpart of __LINE__ from C++ in Ruby?
    By RLMuller in forum Ruby
    Replies: 5
    Last Post: September 15th, 03:57 AM
  5. eval
    By Adrian in forum PHP Development
    Replies: 5
    Last Post: September 9th, 10:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139