Undefined values
For languages which have an explicit notion of an undefined value, (as opposed to a NULL value), identify and exercise those language's mechanisms for identifying and manipulating a variable's value's status as being undefined
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
Perl
<lang perl>#!/usr/bin/perl -w use strict;
- Declare the variable
our $var;
- Check to see whether it is defined
print "var is undefined at first check\n" unless defined $var;
- Give it a value
$var = "Chocolate";
- Check to see whether it is defined after we gave it the
- value "Chocolate"
print "var is undefined at second check\n" unless defined $var;
- Give the variable an undefined value.
$var = undef;
- Check to see whether it is defined after we've explicitely
- given it an undefined value.
print "var is undefined at third check\n" unless defined $var;
- Give the variable a value of 42
$var = 42;
- Check to see whether the it is defined after we've given it
- the value 42.
print "var is undefined at fourth check\n" unless defined $var;
- Because most of the output is conditional, this serves as
- a clear indicator that the progrma has run to completion.
print "Done\n";</lang>
Results in:
var is undefined at first check var is undefined at third check Done