First, whats meant by:
I ran into an issue that involved quite low-level transformations and as it turned out
To your comparison: The code sequence (*)
$string='7';
$num=$string+0
gives (*):
C:\>perl -MO=Concise,-exec -e"$string='7';$num=$string+0"
1 <0> enter
2 <;> nextstate(main 1 -e:1) v:{
3 <$> const[PV "7"] s
4 <#> gvsv[*string] s
5 <2> sassign vKS/2
6 <;> nextstate(main 1 -e:1) v:{
7 <#> gvsv[*string] s
8 <$> const[IV 0] s
9 <2> add[t4] sK/2
a <#> gvsv[*num] s
b <2> sassign vKS/2
c <@> leave[1 ref] vKP/REFC
and the sequence (**)
$string='7';
$num=int($string)"
gives (**)
C:\>perl -MO=Concise,-exec -e"$string='7';$num=int($string)"
1 <0> enter
2 <;> nextstate(main 1 -e:1) v:{
3 <$> const[PV "7"] s
4 <#> gvsv[*string] s
5 <2> sassign vKS/2
6 <;> nextstate(main 1 -e:1) v:{
7 <#> gvsv[*string] s
8 <1> int[t4] sK/1
9 <#> gvsv[*num] s
a <2> sassign vKS/2
b <@> leave[1 ref] vKP/REFC
-e syntax OK
The Difference is (*)
8 <$> const[IV 0] s
9 <2> add[t4] sK/2
compared to (**)
8 <1> int[t4] sK/1
so there shouldn't be too much difference
Regards
mwa
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.