On Oct 1, 2012, at 2:44 AM, li panda wrote:

> Here is two beginners questiones ~  to trouble you
> 
> 1.print "This is the ${times}th time.\n";
> what is the function of "{}"

The "{}" in ${times} specify that the value of the scalar variable $times 
should be interpolated into the string and followed by the characters "th". 
Without the {}, the string would be " ... $timesth ... ", and Perl would look 
for the $timesth variable instead of $times.

> 
> 2.print "0x30"          + 0,  "\n";
> why output is 0 not 0x30
> 

The plus sign forces Perl to evaluate the arithmetic expression "0x30" + 0. The 
string "0x30" will evaluate to the numerical value 0, because Perl scans the 
string from left-to-right, accepting and processing all valid numerical 
characters. When it gets to the 'x', it stops, returning a value of zero. The 
Perl string parser does not evaluate hexadecimal strings.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to