The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

# NAME

MFor - A module for multi-dimension looping.

# SYNOPSIS

``````  use MFor;
mfor {
my @args = @_;  # get a,x,1 in first loop
print "Looping..  " , join(',',@_) , "\n";
}  [
[ qw/a b c/ ],
[ qw/x y z/ ],
[ 1 .. 7 ],
];``````

or

``````  MFor->it( 1 .. 7 )->it(  'a' ... 'z' )->do( sub {

# do something
my @args = @_;

});``````

``````  for my \$a ( qw/a b c/ ) {
for my \$b ( qw/x y z/ ) {
for my \$c (  1 .. 7 ) {
print "Looping..  " , join(',',\$a,\$b,\$c) , "\n";
}
}
}``````

## mfor

``````    mfor {
my @args = @_;  # get a,x,1 in first loop
print "Looping..  " , join(',',@_) , "\n";
}  [
[ qw/a b c/ ],
[ qw/x y z/ ],
[ 1 .. 7 ],
];``````

## it

iterator with hash reference

``````    MFor->it({ L1 => qw|a b c| })->it({ L2 =>  qw|X Y Z| })
->do(sub {
my \$args = shift;

print \$args->{L1};
print \$args->{L2};

});``````

conditon with iterator

``````    MFor->it({ L1 => qw|a b c| })->when( qw|L1 eq 'a'|  )->do( sub {

# only do something when L1 equal to 'a'
my \$args = shift;

})``````

# DESCRIPTION

This module provides another way to do loop.

mfor