|
Posted by John W. Krahn on February 2, 2008, 12:59 am
Please log in for more thread options Liang Wang wrote:
>> Liang Wang wrote:
>>> eval "07" gets 7 but eval "08" gets an undefined value. I tested perl
>>> 5.8.8 on fedora 8 and ubuntu.
>>> Is there any difference between those two eval statements? Is this a
>>> bug?
>> No, there is no difference in the eval statements. The problem is that
>> "08" is not a valid octal number.
>
> Got it. Thanks.
>
> I've tested "06", but not "09". What I really want to do is to
> transform string "08" to integer 8. But in this case, eval doesn't
> treat "08" as string, as you said.
The string "08" is already the integer 8.
$ perl -le' $x = "08"; print $x; print $x + 1'
08
9
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
|