Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Is there a better way to use the line number in a quoted string than __LINE__?

by stevieb (Canon)
on Mar 07, 2021 at 18:44 UTC ( [id://11129289]=note: print w/replies, xml ) Need Help??


in reply to Is there a better way to use the line number in a quoted string than __LINE__?

Many great answers so far, but another option... printf()!

printf("%d looks very nice\n", __LINE__);

Easy to read, not a whole lot of crazy syntax, and very easy to update later if new variables are needed in the output (ie. don't have to trudge through making sure you're not breaking the concatenations).

Replies are listed 'Best First'.
Re^2: Is there a better way to use the line number in a quoted string than __LINE__?
by LanX (Saint) on Mar 07, 2021 at 20:55 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129289]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found