Look_up Engine  
  email how to  
  search engine  
  ask us  


Perl scripting


OO Perl

Perl & Databases

Search a word:

© The scientific sentence. 2010

Perl More functions
More functions

1.Multi-Line Strings

In Perl, we can handle a multi-line string by using a ENDOFDOCUMENT. Example: --------- #!c:\www\Perl\bin $sentence = <<"ENDOFDOCUMENT"; Best regards, Have a nice day! Take care, and All the best of luck .. ENDOFDOCUMENT warn "The sentence is:\n '$sentence'"; outputs: C:\www\PERL> The sentence is: 'Best regards, Have a nice day! Take care, and All the best of luck .. ' at C:\www\PERL\ line 10. 2 Numeric Functions abs: --- To get the absolute value of a number, we use: abs($number); # var1 is 3.4 int: --- To convert a floating point number to an integer, we use int($float_number); round: ----- To round a float, use the "C" style: to the nearest intege $number = 23.56 sprintf("%.xf", $number; "x" can take the value 0 ( nearest integer), 1 ,2 ... sprintf: -------- To convert a number into string format, use: sprintf ( FORMAT_STRING, LIST_OF_VALUES ); Example: my $number = 2.17456; my $number = sprintf("%05.3f",$number); Will be converted into a string of 5 characters and 3 decimals; that is: 2.175 To convert a string into a number, we add 0: Example My $number1 = '34.786'; my $number2 = $number1+0; random: ------- Use rand Example: $any_number = rand; print 100000000.00 * $any_number ; conversion: ---------- Convert a number to a string: my $number = 3.1416 my $word= $number .= ''; will becomes a string: '3.14116'

chimie labs
scientific sentence
green cat

© Scientificsentence 2007. All rights reserved.