#!/usr/bin/perl -w use strict; #try to catch as many type errors as possible #setup a few initial things $\="\n"; my $a=4; my $ref_a=\$a; my @b=("b",5); my $ref_b=\@b; my %c=("c",6); my $ref_c=\%c; print $a+@b; #coerce array into number print $a+$ref_b; #coerce reference into number my $d=eval %c; #coerce hash into string print "d=$d"; #amusing result my @e=%c;print "@e"; #hashes and arrays are different types. Oh wait +... print "c=$_" for %c; my @t=12; #coerce number into array print @t; print 0+@t; print "\\4 = ".(\4->{"what???"}); #??? 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"; no warnings; my %i=$ref_a; print %i; #apparently hashes can be scalar refs... no strict; $$ref_a->[88]=7; print $$ref_a->[88]
In reply to strong typing
by sleepingsquirrel
in thread (Completely OT) - Hero(i)n programming language on Slashdot
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |