N
Nene
Hello,
What I'm trying to do is once my inner loop reaches a count of 5, I
want it to exit the while statement and go back to the foreach loop.
But it hangs after it reaches '5' and takes a long time for it go to
to the second iteration (really large files) of the for foreach loop:
#!/usr/bin/perl -w
use strict;
my @LIST = qw/
server_1
server_2
/;
my $count = 0;
FIRST: foreach my $SERVER (@LIST) {
my $ssh = "ssh $SERVER";
my $cmd = "perl -ne 'print' /server/directory/file";
open(SSH, "$ssh $cmd |") || die "ssh: $!";
print "\n";
print "Connected to $SERVER\n";
LINE: while (my $current_line = <SSH>) {
if ($current_line =~ /Failed at the server/) {
$count++;
print "$current_line\n";
next FIRST if $count == 5;
}
}
}
What I'm trying to do is once my inner loop reaches a count of 5, I
want it to exit the while statement and go back to the foreach loop.
But it hangs after it reaches '5' and takes a long time for it go to
to the second iteration (really large files) of the for foreach loop:
#!/usr/bin/perl -w
use strict;
my @LIST = qw/
server_1
server_2
/;
my $count = 0;
FIRST: foreach my $SERVER (@LIST) {
my $ssh = "ssh $SERVER";
my $cmd = "perl -ne 'print' /server/directory/file";
open(SSH, "$ssh $cmd |") || die "ssh: $!";
print "\n";
print "Connected to $SERVER\n";
LINE: while (my $current_line = <SSH>) {
if ($current_line =~ /Failed at the server/) {
$count++;
print "$current_line\n";
next FIRST if $count == 5;
}
}
}