#EXAMPLE 1
my $a = "0001";
print "a 1 as string is:$a\n";
$a+=0; # A trick! forces numeric context!!!
print "a 1 as number is:$a\n";
#EXAMPLE 2
my $b="01";
if ($a eq $b)
{
print "$a is eq $b\n";
}
else
{
print "$a is NOT eq $b\n";
}
if ($a == $b)
{
print "$a is == $b\n";
}
else
{
print "$a is NOT == $b\n";
}
#EAMPLE 3
my $string_eight="8";
my $numeric_eight = 8;
####
if ($string_eight eq $b)
{
print "string $string_eight is eq number $numeric_eight\n";
}
else
{
print "string $string_eight is NOT eq number $numeric_eight\n";
}
####
my %hash = ('8'=>"string eight", 8 =>'number 8');
print "hash key uses the stringified version of 8: $hash{'8'} or $hash{$numeric_eight}\n";
__END__
a 1 as string is:0001
a 1 as number is:1
1 is NOT eq 01
1 is == 01
####
#string 8 is NOT eq number 8
####
hash key uses the stringified version of 8: number 8 or number 8