in reply to Help with for loop
Hello,
Actually, for each iteration in the for loop you are done with NB_FILE. In that case, you have to take fresh NB_FILE. This is one way of doing!
#!/usr/bin/perl use warnings; use strict; system "autorep -J NB% | egrep -v \"Job Name|___\" | awk '{print \$1}' + | sed '/^\$/d' | sort > NB_JIL.txt"; chomp(my @server_names = <>); my $iteration_number = 1; for my $backup_job (@server_names) { open NB_FILE, '<', "/users/home/mkar/Perl_scripts/NB_JIL.txt" or die " +Couldn't open Netbackup file!"; print ":$iteration_number:\n"; print "$backup_job\n"; print (grep /$backup_job/, <NB_FILE>); $iteration_number ++; close NB_FILE or die "Couldn't close the file properly!" }
|
|---|