Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL abs Function
Syntax
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
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
|
|

|
|
|