Array::Each::Tutorial 0.02
Sponsored Links
Array::Each::Tutorial 0.02 Ranking & Summary
File size:
0.020 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
832
Date added:
2007-07-14
Publisher:
Brad Baxter
Array::Each::Tutorial 0.02 description
Array::Each::Tutorial - POD giving various examples how to use Array::Each.
SYNOPSIS
man Array::Each
man Array::Each::Tutorial
or
perldoc Array::Each
perldoc Array::Each::Tutorial
Overview
This tutorial contains only POD, so dont do this:
use Array::Each::Tutorial; # dont do this
Rather, simply read the POD (as you are doing). But first, please read the docs for Array::Each, because the whole scoop is there.
This tutorial is intended to augment those docs with examples showing situations where you might want to use Array::Each instead of other techniques.
EXAMPLES
Parallel Arrays vs. Using a Hash
First of all, use a hash. Its almost always the best solution if you want to associate a "key" with a "value". And there are modules available that will let you do wonderful things with hashes, like keeping the keys sorted or keeping them in the order they were added.
So given a hash, you might at some point want to do this:
my %h = ( a=>1, b=>2, c=>3, d=>4, e=>5 );
while( my( $k, $v ) = each %h ) {
# ... do something with $k and $v ...
}
On the other hand, if parallel arrays better implement your algorithm, then you may find you want to do something like this:
my @k = qw( a b c d e );
my @v = qw( 1 2 3 4 5 );
for my $i ( 0 .. $#k ) {
my( $k, $v ) = ( $k[$i], $v[$i] );
# ... do something with $k and $v (and maybe $i) ...
}
Using Array::Each, you could do the same thing this way:
use Array::Each;
my @k = qw( a b c d e );
my @v = qw( 1 2 3 4 5 );
my $obj = Array::Each->new( @k, @v );
while( my( $k, $v, $i ) = $obj->each ) {
# ... do something with $k and $v (and maybe $i) ...
}
If you dont need $i at all, you can leave it out, e.g.,
while( my( $k, $v ) = $obj->each ) {
# ... do something with $k and $v ...
}
If you have more than two parallel arrays, include them all in the call to new() and add as many "capture" variables as you need, e.g.,
my @k = qw( a b c d e );
my @v = qw( 1 2 3 4 5 );
my @p = qw( - + ~ = : );
my $obj = Array::Each->new( @k, @v, @p );
while( my( $k, $v, $p, $i ) = $obj->each ) {
# ... do something with $k, $v, and $p (and maybe $i) ...
}
SYNOPSIS
man Array::Each
man Array::Each::Tutorial
or
perldoc Array::Each
perldoc Array::Each::Tutorial
Overview
This tutorial contains only POD, so dont do this:
use Array::Each::Tutorial; # dont do this
Rather, simply read the POD (as you are doing). But first, please read the docs for Array::Each, because the whole scoop is there.
This tutorial is intended to augment those docs with examples showing situations where you might want to use Array::Each instead of other techniques.
EXAMPLES
Parallel Arrays vs. Using a Hash
First of all, use a hash. Its almost always the best solution if you want to associate a "key" with a "value". And there are modules available that will let you do wonderful things with hashes, like keeping the keys sorted or keeping them in the order they were added.
So given a hash, you might at some point want to do this:
my %h = ( a=>1, b=>2, c=>3, d=>4, e=>5 );
while( my( $k, $v ) = each %h ) {
# ... do something with $k and $v ...
}
On the other hand, if parallel arrays better implement your algorithm, then you may find you want to do something like this:
my @k = qw( a b c d e );
my @v = qw( 1 2 3 4 5 );
for my $i ( 0 .. $#k ) {
my( $k, $v ) = ( $k[$i], $v[$i] );
# ... do something with $k and $v (and maybe $i) ...
}
Using Array::Each, you could do the same thing this way:
use Array::Each;
my @k = qw( a b c d e );
my @v = qw( 1 2 3 4 5 );
my $obj = Array::Each->new( @k, @v );
while( my( $k, $v, $i ) = $obj->each ) {
# ... do something with $k and $v (and maybe $i) ...
}
If you dont need $i at all, you can leave it out, e.g.,
while( my( $k, $v ) = $obj->each ) {
# ... do something with $k and $v ...
}
If you have more than two parallel arrays, include them all in the call to new() and add as many "capture" variables as you need, e.g.,
my @k = qw( a b c d e );
my @v = qw( 1 2 3 4 5 );
my @p = qw( - + ~ = : );
my $obj = Array::Each->new( @k, @v, @p );
while( my( $k, $v, $p, $i ) = $obj->each ) {
# ... do something with $k, $v, and $p (and maybe $i) ...
}
Array::Each::Tutorial 0.02 Screenshot
Array::Each::Tutorial 0.02 Keywords
POD
Tutorial 0.02
1 2 3 4
1 2
1 2 3
1 2 3 4 5
2 3 4 5
c d e
3 4 5
2 3 4
to use
v
k
QW
examples
something
Bookmark Array::Each::Tutorial 0.02
Array::Each::Tutorial 0.02 Copyright
WareSeeker periodically updates pricing and software information of Array::Each::Tutorial 0.02 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Array::Each::Tutorial 0.02 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
1 2 3 4 5 6 7 8 9 10
1 2 3 4 lyrics
1 2 3 4 tell me that you love me more
jurassic park 1 2 3 4 dinosaurs
4 3 2 1 morte
1 2 3 4 plain white t's
ohio issues 2 3 4 5
4 3 2 1 diet liquid oz health from the
1 2 3 4 5 6 7 8 9 0
1 2 3 4 feist
1 2 3 4 plain white t's lyrics
5 4 3 2 1
2 3 4 5 6 step
List of Barney & Friends episodes and videos
10 9 8 7 6 5 4 3 2 1
feist 1 2 3 4
1 2 3 4 plain white tees
superman 1 2 3 4
Related Software
Array::Utils module contains small utils for array manipulation. Free Download
yagg::Tutorial is a Perl module that contains a tutorial for yagg. Free Download
Array::Unique is a tie-able array that allows only unique values. Free Download
Tie::Array::RestrictUpdates can limit the number of times you change elements in an array. Free Download
Apache Users project is an Apache username enumerator, via /~username requests. Free Download
Rose::DB::Object::Tutorial is a guided tour of the basics of Rose::DB::Object. Free Download
Test::Unit::Tutorial is a Perl module that contains a tutorial on unit testing. Free Download
XML::Smart::Tutorial is a Perl module with tutorials and examples for XML::Smart. Free Download
Latest Software
Popular Software
Favourite Software