#!/usr/bin/perl -w # notclever.pl # Rudimentary examples of array, hash, tied hash # Updated using Komodo beta 1.0.0 build 12686 on Win2k # Tested: Perl 5.00503 on Debian # ActivePerl 5.006 on Win2k use strict; use Tie::IxHash; print "\nPASSEL O' PRINTS"; print "\n 1 script : $0"; print "\n 2 executable : $^X $]"; print "\n 3 host OS : $^O"; print "\n 4 start time : $^T"; print "\n"; print "\nARRAY+FOREACH"; my @varlist = ( "\n 1 script : $0", "\n 2 executable : $^X $]", "\n 3 host OS : $^O", "\n 4 start time : $^T", ); foreach (@varlist) { print; } print "\n"; print "\nHASH+WHILE"; my %varhash = ( ' 1 script' => "$0" , ' 2 executable' => "$^X $]" , ' 3 hostOS' => "$^O" , ' 4 starttime' => "$^T" , ); while((my $key, my $value) = each(%varhash)) { print "\n", $key, " is ", $value; } print "\n"; print "\nTIED HASH+FOR"; tie my %tiedhash, "Tie::IxHash"; %tiedhash = ( ' script' => "$0" , ' executable' => "$^X $]" , ' hostOS' => "$^O" , ' starttime' => "$^T" , ); for my $key (keys %tiedhash) { print "\n", $key, " is ", $tiedhash{$key}; } print "\n";