Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL abs Function



Syntax

abs VALUE

abs


Definition and Usage

Returns the absolute value of its argument. If pure interger value is passed then it will return it as it is but if a string is passed then it will return zero. If VALUE is omitted then it uses $_

Return Value

  • Returns the absolute value of its argument.

Example

Following is the piece of code

#!/usr/bin/perl

$par1 = 10.25;
$par2 = 20;
$par3 = "ABC";

$abs1 = abs($par1);
$abs2 = abs($par2);
$abs3 = abs($par3);

print "Abs value of par1 is $abs1\n" ;
print "Abs value of par2 is $abs2\n" ;
print "Abs value of par3 is $abs3\n" ;

This will produce following result

Abs value of par1 is 10.25
Abs value of par2 is 20
Abs value of par3 is 0


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names