Hello all,
Below is a snippet of code I am working on.
As you can see it is taking three variables from the command line, one being $sched_name and then looping through a test file to match a portion of the $sched_name with each entry in the prefix file. The problem is the $prefix is never getting set. I know for certain that I input EWSRDBUD on the comand line that ends up being the $sched_name, it should match the prefix in the file I am looking for which is EW, but it does not.
Seems that my:
next unless ($sched_name =~ /$_/);
is not matching but it should when EWSRBUD is compared to EW as EWSRBUD does contain EW. I tried anchoring the expression with:
next unless ($sched_name =~ /^$_/);
but no joy!
OUTPUT:
Any help is appriciated.
Nick
If at first you don't succeed, don't try skydiving.
Below is a snippet of code I am working on.
Code:
use strict;
open (PREFIX, "/home/mt71124/scripts/tws_prefix.txt") or die ("Error opening prefix file: $?");
my ($cpu, $sched_name, $job_name ) = @ARGV;
my $count = scalar(@ARGV);
chomp ($cpu,$sched_name,$job_name);
my $prefix;
print "Sched = $sched_name\n";
while (<PREFIX>) {
chomp;
next unless ($sched_name =~ /$_/);
$prefix = $_;
last;
}
print "prefix = $prefix\n";
close PREFIX;
As you can see it is taking three variables from the command line, one being $sched_name and then looping through a test file to match a portion of the $sched_name with each entry in the prefix file. The problem is the $prefix is never getting set. I know for certain that I input EWSRDBUD on the comand line that ends up being the $sched_name, it should match the prefix in the file I am looking for which is EW, but it does not.
Seems that my:
next unless ($sched_name =~ /$_/);
is not matching but it should when EWSRBUD is compared to EW as EWSRBUD does contain EW. I tried anchoring the expression with:
next unless ($sched_name =~ /^$_/);
but no joy!
OUTPUT:
Code:
# ./maestro_inst.pl PRDAI085 EWSRDBUD EWDBABKUP
Sched = EWSRDBUD
prefix =
Any help is appriciated.
Nick
If at first you don't succeed, don't try skydiving.