Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# undef

Perl 5 version 10.1 documentation
Go to top

# undef

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- undef EXPR

- undef

  Undefines the value of EXPR, which must be an lvalue. Use only on a scalar value, an array (using `@` ), a hash (using `%` ), a subroutine (using `&` ), or a typeglob (using `*` ). (Saying `undef $hash{$key}` will probably not do what you expect on most predefined variables or DBM list values, so don't do that; see delete.) Always returns the undefined value. You can omit the EXPR, in which case nothing is undefined, but you still get an undefined value that you could, for instance, return from a subroutine, assign to a variable or pass as a parameter. Examples:

          undef $foo;    undef $bar{'blurfl'};      # Compare to: delete $bar{'blurfl'};    undef @ary;    undef %hash;    undef &mysub;    undef *xyz;       # destroys $xyz, @xyz, %xyz, &xyz, etc.    return (wantarray ? (undef, $errmsg) : undef) if $they_blew_it;    select undef, undef, undef, 0.25;    ($a, $b, undef, $c) = &foo;       # Ignore third value returned

  Note that this is a unary operator, not a list operator.

Recently read

Tools

- Preferences