in reply to ask about array and hash

Or you can loop through them to print the elements:
#!/usr/bin/perl -w use strict; my @array = qw(a b c d e f g); my %hash = ( '1st' , 'a', '2nd' , 'b', '3rd' , 'c', ); while (<@array>) { print; } foreach my $key (sort keys %hash) { print "$key: $hash{$key}\n"; }

Replies are listed 'Best First'.
(crazyinsomniac) Re^2: ask about array and hash
by crazyinsomniac (Prior) on Jan 17, 2002 at 10:01 UTC
      Indeed. I wanted to show that there was more than one way to print and or access the data in an array or hash. Hence my using a foreach loop in the second example, also showing use of sort(). I am sorry if my globbing offended you in anyway. -xtype