Generated: Tue Feb 2 17:54:21 2010 from arrayref01.pl 2007/02/14 866.
#!/perl -w # *NAME* arrayref01.pl # AIM: Passing and using an ARRAY REFERENCE - ie pass \@used_colors to a functions, # then address the members of the arrya reference using the ${$arrayref}[NN] format ... use strict; use warnings; require 'logfile.pl' or die "Unable to load logfile.pl ...\n"; # log file stuff my ($LF); my $outfile = 'temp.'.$0.'.txt'; my @used_colors = ("#aabbcc", "#bbaacc", "#ffffff"); open_log($outfile); prt( "$0 ... Hello, World ...\n" ); $used_colors[5] = "#000000"; out_an_array( \@used_colors ); close_log($outfile,1); exit(0); sub out_an_array { my ($ar) = shift; my $cnt = scalar @{$ar}; prt( "Got $cnt count ...\n" ); for (my $i = 0; $i < $cnt; $i++) { if (defined ${$ar}[$i]) { my $val = ${$ar}[$i]; prt( "$i $val ...\n" ); } else { prt( "$i undefined ...\n" ); } } } # eof