davido has the correct answer but for a visual representation of his explanation, you could always use Devel::Peek ...
...
use Devel::Peek;
....
print Dump( $bottom );
my $middle = int(($bottom + $top) / 2);
print Dump( $bottom );
....
yields:
Enter the bottom most number: 1
Enter the top most number: 10
Hit enter once you have your number!
SV = PVMG(0x1009725b0) at 0x100847c98
REFCNT = 1
FLAGS = (PADMY,POK,pPOK)
IV = 0
NV = 0
PV = 0x10020a3f0 "1\n"\0
CUR = 2
LEN = 16
SV = PVMG(0x1009725b0) at 0x100847c98
REFCNT = 1
FLAGS = (PADMY,IOK,POK,pIOK,pPOK)
IV = 1
NV = 0
PV = 0x10020a3f0 "1\n"\0
CUR = 2
LEN = 16
Is it 5(l/h/t)?:
and from this, you can see no chomping has taken place but perl's DWIMery has taken your scalar (SV) and taken the string value (PV) and set its integer value (IV).
-
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.
|