k_grdn has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
As a perl beginner I'm having problems in my programs, when storing items in array, I then grep or match theses items in another array but get mixed results due to repetitive use of for loops.
Example
my @chains = qw(INPUT OUTPUT FORWARD); my @rules = open_file($rules); foreach (@chains) { for my $rule (@rules) { print $rule if ( $_ eq $rule ); } }
I understand the results and regularly use Dumper, can someone advise better practice?
Also I can match txt between markers but have problems in the same manner using array items as string to be matched.
i.e
my FILE>> INPUT -p tcp -s 10.0.12.1 -j ACCEPT FORWARD -p udp -d 10.0.12.4 -j ACCEPT OUTPUT -p tcp -s 10.0..12.5 -j ACCEPT FILE my @chains = qw(INPUT OUTPUT FORWARD); I Loop the array open then file and try to match first array item push + on to new array until then next array item match.
Many thanks,
k_grdn
20081016 Janitored by Corion: Removed H6 tags from prose, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple Array Loops
by moritz (Cardinal) on Oct 11, 2008 at 16:53 UTC | |
|
Re: Multiple Array Loops
by nobull (Friar) on Oct 12, 2008 at 16:45 UTC | |
by k_grdn (Novice) on Oct 12, 2008 at 20:16 UTC | |
by k_grdn (Novice) on Oct 12, 2008 at 20:58 UTC | |
by k_grdn (Novice) on Oct 18, 2008 at 16:41 UTC |