- 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 ref Function
Description
This function returns a true value if EXPR, or $_ if EXPR is not supplied, is a reference. The actual value returned also defines the type of entity the reference refers to.
The built-in types are −
- REF
- SCALAR
- ARRAY
- HASH
- CODE
- GLOB
- LVALUE
- IO::Handle
If a variable was blessed with the bless() function, then the new data type will be returned. The new data type will normally be a class name.
Syntax
Following is the simple syntax for this function −
ref EXPR ref
Return Value
This function returns empty string if not a reference and string if a reference in Scalar Context.
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl -w $foobar = { }; bless($foobar, 'ATMPCLASS'); print "ref() \$foobar is now in class ", ref($foobar), "\n";
When above code is executed, it produces the following result −
ref() $foobar is now in class ATMPCLASS
perl_function_references.htm
Advertisements