Gossamer Forum
Home : General : Perl Programming :

A simple rather stupid question

Quote Reply
A simple rather stupid question
$line = "$in{'chars'}";
$linecount = $line/65;
-----------------------

Simple division of $line with 65 e.g.

$line = 124
$linecount = 124/65

The answer comes something like this: 1.90769230769231

I don't decimal figures....how to get result in round figures????

Plz help this novice programmer.

Quote Reply
Re: [zeshan] A simple rather stupid question In reply to
It's in the perl faq

From a command line type

Code:
perldoc -q round

Short answer: use printf

--mark
Quote Reply
Re: [Mark Badolato] A simple rather stupid question In reply to
You are talking Greek to me. I can't work on the command line and I have failed to find where the FAQs are present on this site for Perl forum.

Can you please provide me a couple of lines that I can add in my existing code.....

Thanks,

Zeshan
Quote Reply
Re: [zeshan] A simple rather stupid question In reply to
In Reply To:
Can you please provide me a couple of lines that I can add in my existing code.....

The best way to learn is to read and try, and experiment. The relevant docs you need are here:

http://www.perldoc.com/...()---Trig-functions-
Quote Reply
Re: [zeshan] A simple rather stupid question In reply to
Code:
$linecount = sprintf("%.0f", $linecount);