I'm new to perl and struggling with this. How can I make the following code iterate asterisk_Output each run of the for loop? At the moment it completes the while loop on the first iteration of the for loop but not on subsequent ones.
open(asterisk_Output, "/usr/sbin/asterisk -rx \"sip show registry\"|") or die $!;
foreach (@monitor_trunks){
while (my $line = <asterisk_Output>) {
#Perform some action... Such as comparing each line.
}
}
The only way I have got it working is by putting the top line within the for loop, but this is un necessary and make multiple calls to the external command.