|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
perl: simple question on string append
I want to append a decimal number to a string. But I want to restrict the number to only 2 decimal points
for e.g: my $output = "\n The number is = "; my $number = 2.3333333; $output = $output . $number; But I want the $output as: "The number is = 2.33"; and not 2.3333333 (I do not want to print $output right now.. I just want it to have the number with only 2 decimal points) can anyone please helpout.. Thanks !!!!!!!!!!!! |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
$result = sprintf("%.2f", $number); |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl script to look for a string in a file and append few lines if the match is found | arunkumarmc | Programming | 1 | 03-04-2011 05:05 PM |
| how to append a string to next line in perl | tprayush | Shell Programming and Scripting | 2 | 04-09-2010 03:58 PM |
| Simple perl question | streetfighter2 | Shell Programming and Scripting | 3 | 12-22-2009 08:33 PM |
| PERL: simple comparing arrays question | hcclnoodles | Shell Programming and Scripting | 5 | 09-07-2009 04:43 PM |
| simple question on string concat | the_learner | Programming | 2 | 08-23-2007 11:09 PM |
|
|