On Dec 22, 2003, at 7:52 AM, Nathan Torkington wrote:
On Dec 22, 2003, at 8:50 AM, Jerry LeVan wrote:print (5.0/9.0)*($ARGV[0]-32.0), " Centigrade\n" ;
I had to grab the Perl book and found "If it looks like a function it is a function".
Y'all ever been bit by this type of misdirection?
All the time.
This seems to be tied to how 'print' does it's machinations, and is true on non-mac machines running 5.6.1 et all whereas the following skips along happily.
printf("%.2f Centigrade\n", (5.0/9.0)*($ARGV[0]-32.0));
since that is doing the
print sprintf("%.2f Centigrade\n", (5.0/9.0)*($ARGV[0]-32.0));
and hence it appears to view
(5.0/9.0)*($ARGV[0]-32.0)
as a resolvable calculation vice a possible function...
alternatively if one does
print STDOUT (5.0/9.0)*($ARGV[0]-32.0) , " Centigrade\n";
one has expressly called out the FILEHANDLE and so the compiler does not have to try and 'work it out' whether that first expression is suppose to be.
alternatively
print "" . (5.0/9.0)*($ARGV[0]-32.0) . " Centigrade\n";
or why I generally TRY to avoid doing anything 'complex' in a simple 'print statement' unless I really need it that way.
ciao drieux
---
