use strict; use File::Find; my %slots = (); my @diaglist; my $directory = "/path/to/directory/that/I/want/to/traverse"; find(\&diag, $directory); sub diag { @diaglist = `cat $_ |grep SLOT`; my $device = $_; foreach $rtr_diag(@diaglist) { unless ($rtr_diag =~ m/Clock|Switch|Power|Processor/) { push @{$slots{$device}}, $rtr_diag; } } foreach $device (sort keys %slots) { my $diag_string = join "", @{$slots{$device}}; print "$device:\n"; print "===========================\n"; print "$diag_string\n\n"; } }
In reply to Nest/Loop/Print - update by Limo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |