- or download this
use strict; #try to catch as many type errors as possible - or download this
print $a+@b; #coerce array into number
- or download this
print $a+$ref_b; #coerce reference into number
- or download this
my $d=eval %c; #coerce hash into string
print "d=$d"; #amusing result
- or download this
my @e=%c;print "@e"; #hashes and arrays are different types. Oh wait
+...
print "c=$_" for %c;
- or download this
my @t=12; #coerce number into array
print @t;
print 0+@t;
- or download this
print "\\4 = ".(\4->{"what???"}); #???
- or download this
print '\\4 = ' . \$4{'what???'};
- or download this
sub test{ return ("a",123) }; #sub returns a list
my $scalar_list=test(); #coerce into scalar
my @array_list=test(); #coerce into array
my %hash_list=test(); #coerce into hash
print "\$scalar_list=$scalar_list\n\@array_list=@array_list";
- or download this
no warnings;
my %i=$ref_a;
print %i; #apparently hashes can be scalar refs...
- or download this
my (%i) = $ref_a;
- or download this
no strict;
$$ref_a->[88]=7;
print $$ref_a->[88]