Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: To infinity and beyond: Embedding loops

by Skeeve (Parson)
on Jul 16, 2003 at 10:01 UTC ( #274750=note: print w/replies, xml ) Need Help??


in reply to To infinity and beyond: Embedding loops

No infinite loop here. But is this really what you wanted?
use Data::Dumper; my @line= qw(a b c); my @angel=qw(1 2 b); for ( $i = 1 ; $i <= $#line ; $i++ ) { $k = $line[$i]; for ( $v = 1 ; $v <= $#angel ; $v++ ) { $j = $angel[$v]; if ( $k =~ m/($j)/i ) { push ( @a, $v ); } else { push ( @b, $v ); } } } print Dumper(\@a, \@b);
prints out:
$VAR1 = [ 2 ]; $VAR2 = [ 1, 1, 2 ];
BTW: Arrays start at 0 not at 1...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://274750]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2022-01-20 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (56 votes). Check out past polls.

    Notices?