bacoms
Programmer
- Jun 14, 2008
- 6
As a relative newbie to perl and CGI, can someone please tell me why the following resolves ok;
use constant DATEWIDTH => 86;
use constant PRICEWIDTH => 60;
my($earliestWidth) = DATEWIDTH + PRICEWIDTH;
print "earliest-cell {width: " . $earliestWidth . "px;}\n";
print "date-cell {width: " . DATEWIDTH . "px;}\n";
print "price-cell {width: " . PRICEWIDTH . "px;}\n";
but the following doesn't;
print "earliest-cell {width: " . DATEWIDTH + PRICEWIDTH . "px;}\n";
Running cgi script in command prompt generates error;
Argument "earliest-cell {width: 86" isn't numeric in addition (+) at fakedheader.cgi line 39.
60px;}
How come I can add the two constants together in the assignment statement but not in the concatenation. (It's nothing to do with constants as I get the same error when I change the constants declarations to variables.)
I suspect this is something simple that I have forgotten or misunderstood but it has got me baffled (but it is Monday morning).
Thanks in advance for any help.
Bryan
use constant DATEWIDTH => 86;
use constant PRICEWIDTH => 60;
my($earliestWidth) = DATEWIDTH + PRICEWIDTH;
print "earliest-cell {width: " . $earliestWidth . "px;}\n";
print "date-cell {width: " . DATEWIDTH . "px;}\n";
print "price-cell {width: " . PRICEWIDTH . "px;}\n";
but the following doesn't;
print "earliest-cell {width: " . DATEWIDTH + PRICEWIDTH . "px;}\n";
Running cgi script in command prompt generates error;
Argument "earliest-cell {width: 86" isn't numeric in addition (+) at fakedheader.cgi line 39.
60px;}
How come I can add the two constants together in the assignment statement but not in the concatenation. (It's nothing to do with constants as I get the same error when I change the constants declarations to variables.)
I suspect this is something simple that I have forgotten or misunderstood but it has got me baffled (but it is Monday morning).
Thanks in advance for any help.
Bryan