print line number

Discussion in 'Perl Misc' started by Michael Goerz, Oct 8, 2006.

  1. Hi,

    is there a way to print the line number of the line that is currently
    executed in a perl script (similar to the $. variable), so that I can
    use it in debugging messages, like this:

    [... perl code ...]

    $i = 5; print ('The value of $i changed to ', $i, "at line ",
    $current_line, "\n") if $DEBUGGING;

    [... perl code ...]

    Thank,
    Michael
     
    Michael Goerz, Oct 8, 2006
    #1
    1. Advertising

  2. Abigail wrote:
    > print "The value of \$i changed to $i at line ", __LINE__, "\n";


    Thanks, that exactly what I meant!

    Michael
     
    Michael Goerz, Oct 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,387
    Matt Humphrey
    Oct 18, 2004
  2. Steve
    Replies:
    5
    Views:
    340
    Martin Ambuhl
    Dec 13, 2004
  3. keto
    Replies:
    0
    Views:
    1,043
  4. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    399
    David Cournapeau
    Dec 30, 2008
  5. Peng Yu
    Replies:
    1
    Views:
    449
    Wei Sun
    Nov 22, 2010
Loading...

Share This Page