in reply to Two meanings of undef
As a number, it is treated as zero. AS a string, it is treated as a null string. As a Boolean, it is treated as 'false'. As a argument to defined, it is the only value for which defined will return 'false'.
?perl -e"$line = undef; print 3 + $line" 3 ?perl -e"$line = undef; print '3' . $line" 3 ?perl -e"$line = undef; print 3 unless $line" 3 ?perl -e"$line = undef; print 3 unless defined $line" 3
Your first example does not do what you think. try it. You probably mean:
$current_time='14:30:05' (undef, $min, $sec)=split /\:/, $current_time
I think of this as an idiomatic use which means exactly what you describe. That field of the assignment is ignored.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: The three features of undef (renamed)
by LanX (Saint) on Aug 16, 2020 at 16:19 UTC |