Perl Tutorial : Perl data types
Perl Tutorial : Perl Operators
Perl Tutorial : Perl loops
Perl Tutorial : Perl Conditionals
Perl Tutorial : Perl Subroutines
Perl Tutorial : Perl regex
Perl Tutorial : Perl Files
Perl Tutorial : Perl & Databases
Perl Tutorial : Perl OOPs
Perl Tutorial : Perl signals
Perl Tutorial : Perl threads
Perl Tutorial : Perl Debugging

Introcution to Perl CGI

Introduction to modperl
Home >> perlfunctions >>

Perl function: abs

Syntax:
abs VALUE
abs
The perl function abs returns the absolute value of the argument VALUE.
  • If VALUE is a pure integer, it will return the integer as it is.
  • If VALUE is a string, it will return 0.
  • If VALUE is omitted, it will use $_.
Example:
#!/usr/bin/perl

$try1 = abs(40.4);
$try2 = abs(40);
$try3 = abs(PERL);

print "abs value of 40.4 is $try1";
print "abs value of 40 is $try2";
print "abs value of PERL is $try3";
Result:
abs value of 40.4 is 40.4
abs value of 40 is 40
abs value of PERL is 0

Perl functions

scalars and strings

lc
ord

regex (regular expressions)

arrays

shift
split

More..

eval
Share |

List of all perl functions
Perl function : split
Perl function: chomp
Perl function: chop
Perl function: chr
Perl function: crypt
Perl function: eval
Perl function: hex
Perl function: lc
Perl function: lcfirst
Perl function: length
Perl function: oct
Perl function: ord
Perl function: shift

Perl examples

  • How to use Data::Dumper?
  • How to parse config file?
  • Include external module in perl..
  • Download perl

    download stable version of perl
    Perl 5.10.1
    Perl interview Questions
    sed tutorial
    awk tutorial

    Join us on Google Groups

    Subscribe to perl
    Email:
    Visit this group
    Perl Jobs


    privacy | sitemap | disclaim | contact us
    © 2009 perlhome.com