Hello Monks, i am new to Perl and am confused on an issue. I have a script that is using two files as input. One contains backup jobnames and the other contains a list of server names. My goal is to use the server names to grep backup jobnames. The script works fine the first time around but does not grep the second backup job (verified it exists). Here is my Perl code:
#!/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 = <>); open NB_FILE, '<', "/users/home/mkar/Perl_scripts/NB_JIL.txt" or die " +Couldn't open Netbackup file!"; my $iteration_number = 1; for my $backup_job (@server_names) { 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!"
This is what it produces:
What am I doing wrong? Thank you in advance !> ./test.pl test.txt :1: puccini NB_ISA_SNOH_puccini_DB_diff NB_ISA_SNOH_puccini_DB_full :2: cgndsdr4 >
In reply to Help with for loop by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |