develooper Front page | perl.dbi.users | Postings from December 2021

RE: [EXTERNAL] Re: select decimal column from mysql

Thread Next
Fennell, Brian
December 20, 2021 15:14
RE: [EXTERNAL] Re: select decimal column from mysql
Message ID:
Variables in perl are “untyped” or better yet “dynamically typed”.
Every variable is a string but will behave like a int or float in the right context.
Conversions from string to int to float and back to string happen automatically and silently.
This may be surprising and confusing if you are coming from java.


perl -e '$v = "123" ; print $v . "\n" ; $v += 2 ; print $v . "\n"; $v /= 2.0 ; print $v . "\n"; print length($v) . "\n"; $v = "(" . $v . ")"; print $v . "\n"'

From: john miky <>
Sent: Monday, December 20, 2021 1:28 AM
Subject: [EXTERNAL] Re: select decimal column from mysql

sorry, please ignore this stupid question, 0.015 is > 0

On Mon, Dec 20, 2021 at 2:19 PM john miky <> wrote:
hmm. it is perl's "problem", not dbi.

On Mon, Dec 20, 2021 at 1:20 PM john miky <> wrote:

I select a decimal column, from mysql with dbi,
the value 0.015 for example,  my ($v) = $dbh->selectrow_array("select price from test limit 1")
it is greater than 0 in perl.

What's the proper way to get a float value ?

The information contained in this electronic mail transmission is intended only for the use of the individual or entity named in this transmission. If you are not the intended recipient of this transmission, you are hereby notified that any disclosure, copying or distribution of the contents of this transmission is strictly prohibited and that you should delete the contents of this transmission from your system immediately. Any comments or statements contained in this transmission do not necessarily reflect the views or position of Radial or its subsidiaries and/or affiliates.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About