Re: array question
- From: mritty@xxxxxxxxx (Paul Lalli)
- Date: Tue, 26 Feb 2008 09:59:00 -0800 (PST)
On Feb 26, 11:07 am, Irfan.Sa...@xxxxxxxxxxxxx (Irfan Sayed) wrote:
Hello All,
I have two arrays contains exact no. of elements. Now what I need to do
is , I want to execute certain commands to each elements of the array at
a time.
It means that I want take first element of first array and first element
of second array and then want to execute certain commands considering
these two elements.
I don't know how should I achieve this in perl.
In addition to the answers already received, you could take advantage
of the List::MoreUtils module from CPAN:
#!/usr/bin/perl
use strict;
use warnings;
use List::MoreUtils qw/zip natatime/;
my @foo = (1, 2, 3);
my @bar = qw/a b c/;
my $it = natatime 2, zip(@foo, @bar);
while (my ($f, $b) = $it->()) {
print "$f - $b";
}
__END__
1 - a
2 - b
3 - c
Paul Lalli
.
- Follow-Ups:
- Re: array question
- From: Rob Dixon
- Re: array question
- References:
- array question
- From: Irfan Sayed
- array question
- Prev by Date: Re: OO question
- Next by Date: Re: Are comments allowed before package declarations in modules?
- Previous by thread: Re: array question
- Next by thread: Re: array question
- Index(es):
Relevant Pages
|