teamassociated has asked for the wisdom of the Perl Monks concerning the following question:
thank you!__DATA__ 'vhost5' => [ 'l02duapofqa_r1', 'l02duapofqa1_d1' ] __CODE__ use strict; use warnings; open (LSMAP, "-|", "/usr/ios/cli/ioscli lsmap -all") or die $!; while ($lsm = (<LSMAP>)) { if ($lsm =~ /^Backing device\s+(\w+)\.\w+$/i) { push @{$vhosts{$host}}, $1; next; } my ($p1, $p2, $p3) = split /\s+/, $lsm; $host = $p1 if defined $p3 && $p1 =~ /^(vhost.*)$/i; } $a="vhost11"; $b="l02duapofqa2_d1"; #use Data::Dumper; print Dumper \%vhosts; OUTER: for my $vhname (sort keys %vhosts) { for my $luname ( @{$vhosts{$a}} ) { grep /$b.*/, @{$vhosts{$luname}}; print "\n$vhname -> $luname\n"; if ( !grep /$a.*/, @{$vhosts{$b}} ) { print "\nincorrect vhost\n"; die; } else { print @{$vhosts{$a}},"\ncorrect\n"; last OUTER; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HoA, grep or exists?
by ikegami (Patriarch) on Nov 20, 2014 at 20:26 UTC | |
by teamassociated (Sexton) on Nov 20, 2014 at 21:03 UTC | |
by teamassociated (Sexton) on Nov 20, 2014 at 21:10 UTC | |
by ikegami (Patriarch) on Nov 21, 2014 at 17:17 UTC | |
|
Re: HoA, grep or exists?
by RonW (Parson) on Nov 20, 2014 at 21:13 UTC | |
by teamassociated (Sexton) on Nov 20, 2014 at 23:16 UTC | |
|
Re: HoA, grep or exists?
by CountZero (Bishop) on Nov 21, 2014 at 07:04 UTC |