- 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 undef Function
Description
This function undefines the value of EXPR. Use on a scalar, list, hash, function, or typeglob. Use on a hash with a statement such as undef $hash{$key}; actually sets the value of the specified key to an undefined value.
If you want to delete the element from the hash, use the delete function.
Syntax
Following is the simple syntax for this function −
undef EXPR undef
Return Value
This function returns undef.
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl -w $scalar = 10; @array = (1,2); print "1 - Value of Scalar is $scalar\n"; print "1 - Value of Array is @array\n"; undef( $scalar ); undef( @array ); print "2 - Value of Scalar is $scalar\n"; print "2 - Value of Array is @array\n";
When above code is executed, it produces the following result −
1 - Value of Scalar is 10 1 - Value of Array is 1 2 2 - Value of Scalar is 2 - Value of Array is Use of uninitialized value $scalar in concatenation (.) or string at main.pl line 12.
perl_function_references.htm
Advertisements