http://qs321.pair.com?node_id=11120786

likbez has asked for the wisdom of the Perl Monks concerning the following question:

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;