The 0 ot 1 debate aside, in this instance indices can easily be avoided. Whether its the right thing to do, depends on the application I guess. I would probably use your version rather than this one.
#!/usr/bin/perl -w use strict; my @firstnames = qw(john jacob jingle heimer smitz); my @lastnames = qw(brown black gray greene purple); my @fullnames; for (@firstnames) { my $lastname = shift @lastnames; # get lastname push @lastnames, $lastname; # put back at the other end push(@fullnames, $_ . " " . $lastname ); } print "$_\n" foreach (@fullnames);
In reply to Re: Array indices
by BrowserUk
in thread Array indices
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |