- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl abs Function
Description
This function 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 $_
Syntax
Following is the simple syntax for this function −
abs VALUE abs
Return Value
This function returns the absolute value of its argument.
Example
Following is the example code showing its basic usage −
#!/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" ;
When above code is executed, it produces the following result −
Abs value of par1 is 10.25 Abs value of par2 is 20 Abs value of par3 is 0
perl_function_references.htm
Advertisements