Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables

Status
Not open for further replies.

1newby1

Programmer
Jun 23, 2006
3
US
I'm new to Perl and I was wondering if there is a way for numerical variables to hold extra zeros, (1.0 instead of 1) I know you can do this in java. Can any one help? thanks!
 
Variables in perl can be string or numeric (or indeed other things like references).
To store 1.0 you just:
Code:
my $var = '1.0';
Wrap it up in quotes to make it a string.
If you alter it with a maths operator then you'll need to reformat it afterwards with something like "sprinf".


Trojan.
 
sprintf documentation

an invaluable resource, bookmark it, also check the FAQ's to see what else is useful online material for learning perl

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top