The system function undef can be used on the right side of split function or array assignment to skip values that you do not need. For example:

$current_time='14:30:05'
(undef, $min, $sec)=$current_time

In this role it is similar to /dev/null in Unix.

But if used on the right side this function deletes the variable from the symbol table, For example

$line=undef; say "Does not exists" unless(defined($line));

Is this correct understanding?

Edited:

A clarification:

In FAT if you delete a file from the directory it is still present but marked as deleted.

So the fact that that the item still present in symbol table but has a special value does not change the fact that semantically it is deleted and its memory can be now reused.

In other words, if the item in a Perl symbol table has value undef for all practical purposes is it that same as deleted item in FAT and should be treated by interpreter developers in the same way as "not found" item. Implementation is is not flawless though. With the use warnings statement "uninitialized value" warnings are not produced for operations like $i+4 or $i++:

[0]  # cat undef_test.pl
#!usr/bin/perl
use warnings;
use strict;
my ($i,$l,$m);
my $j=$i;
my $k=$l++;
print "m=$m;j=$j,k=$k\n";

[0]  # perl  undef_test.pl
Use of uninitialized value $m in concatenation (.) or string at undef_test.pl line 7.
Use of uninitialized value $j in concatenation (.) or string at undef_test.pl line 7.
m=;j=,k=0

NOTE:

I think undef is not a value, as many here assume, but a function, So
$X=undef;
actually means in Perl:
$X=undef();
and is equivalent to
undef $X;

In reply to Two meanings of undef by likbez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.