Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Chomping numbers?

by derby (Abbot)
on Jul 18, 2013 at 11:53 UTC ( #1045076=note: print w/replies, xml ) Need Help??


in reply to Re^2: Chomping numbers?
in thread Chomping numbers?

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).

-derby

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1045076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-05-22 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (80 votes). Check out past polls.

    Notices?