Converting String Scalar Number


Converting a string scalar into a number.



To convert a string scalar to a number, just add zero.

Sometimes Perl calculations get a bit screwed, when Perl decides it is dealing with a string – not a number.



Here is the code to fix it up:

print $scalar + 0;



[tags]Scalars, Perl Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *