Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 ( #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 (Sage) 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? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-05-23 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?