Hello everyone. I am often annoyed that this code:
#!/usr/bin/perl
print "Line [ ", __LINE__, " ] looks very nice\n";
print "Line [ __LINE__ ] is taken as a string-literal\n";
#print "Line [ @{[__LINE__}] is a syntax error\n";
produces this result:
Line [ 2 ] looks very nice.
Line [ __LINE__ ] is taken as a string-literal.
I would much prefer the syntax of Line 3, or some convenient token
such as $LINE (or $__LINE__ or whatever I can just embed in
double-quotes).
Line 5 is still a lot of fanning-about, but it doesn't even compile.s/5/3/
The syntax of Line 2 works OK, but it is a lot of fanning-about that
often makes me reluctant to include this useful bit of debugging
information.
Hello everyone. I am often annoyed that this code:
#!/usr/bin/perl
print "Line [ ", __LINE__, " ] looks very nice\n";
print "Line [ __LINE__ ] is taken as a string-literal\n";
#print "Line [ @{[__LINE__}] is a syntax error\n";
produces this result:
Line [ 2 ] looks very nice.
Line [ __LINE__ ] is taken as a string-literal.
I would much prefer the syntax of Line 3, or some convenient token such as $LINE (or $__LINE__ or whatever I can just embed in double-quotes). Line 5 is still a lot of fanning-about, but it doesn't even compile.
The syntax of Line 2 works OK, but it is a lot of fanning-about that often makes me reluctant to include this useful bit of debugging information.
Is there a better way to include the __LINE__ information without all this fanning-about?
Thanks for reading.
- David
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 86:48:57 |
Calls: | 6,658 |
Files: | 12,203 |
Messages: | 5,333,873 |