Elias Assmann wrote: > On Tue, Apr 01, 2003 at 10:42:57PM -0800, R. Joseph Newton wrote: > > > Neither language is strongly typed, as C, Java, or VB are. Although > > both are type-sensitive, they still restrict identifiers only by > > contaiment class. > > Could you elaborate on that? What do you mean by "type-sensitive"
They both respond to implicit cues as to data type: my $var1 = "Hi"; my $var2 = "2"; print $var1 + 1 . "\n"; print $var1 + 1 . "\n"; Print $var1 . ", there.\n"; print $var2 . ", there \n"; in each case above, the language first recognizes that the var is receiving a string. The it converts the string as called for to any numerical value it may express. We know that it does not handle numerical operations in the same way as string operations. > and > "restrict identifiers ..."? In genral-purpose use we declare Perl variables as one of three containment classes: $ scalar @ array % hash Perl strictly enforces the difference, although it does allow for conversions through assignment. #!perl -w #!perl -w use strict; my $my_var = 2; my @my_var = (9, 2, 3); my %my_var = ('4', 5, '3', 6); print "$my_var\n"; print "\n"; foreach (@my_var) { print "$_\n"; } print "\n"; foreach (keys %my_var) { print "$_: $my_var{$_}\n"; } print "\n"; YIELDS: Howdy, podner! E:\d_drive\perlStuff>containment.pl 2 9 2 3 4: 5 3: 6 Call it what one will each my_var knows which containment class it was declared in. erl will not allow operations that are not appropriate for the type of containment class being addressed. Although Perl will issue a warning for implicit casts between numeric and string, it will still allow them: my $var3 = "cat"; my $var4 = "dog"; if ($var4 > $var3) { print "dogs are greater than cats\n"; } else { print "Mroowwwwrrrrr\n"; } When the above code is run without warnings, the output is simply: Mroowwwwrrrrr OTOH, if you do this my @my_var2 = (9, 2, 3); ... $my_var2{'my_key'} = "Beat the system"; without warnings turned on, but using strict: Global symbol "%my_var2" requires explicit package name at E:\d_drive\perlStuff\ containment.pl line 17. Execution of E:\d_drive\perlStuff\containment.pl aborted due to compilation erro rs. Without strict, of course, Perl will let you go ahead and create the new hash %my_var implicitly. Hmmmm, you know, the more I play with this, the less I see any quantum difference between Perl's handling of differences between primitive data types and its handling of differences between containment types. With either situation, if it sees a sensible conversion to make, it will make it. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]