Hello. I'm doing an if/elsif/elsif. It is doing if. Then elsif and elsif. I just want it to do one. eit +her if or elsif. But not both. Here is what I have: #!/usr/bin/perl -w use strict; my $agent = "best1agent_start"; my $bgs=<<HERE; 'bgs') /usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1collect + -q>>\$LOG 2>>\$LOG ;; HERE my $collect = " /usr/bin/su - patrol /usr/adm/best1_default/bgs/scr +ipts/best1collect -q>>\$LOG 2>>\$LOG\n"; my $cf_dir = "/export/home/f358118/sysedge"; open SH_FILES, "sys.sh" or die "Error: $!"; my @sh_f=<SH_FILES>; close SH_FILES; foreach my $sh(@sh_f){ chomp $sh; open(OUT, ">/$cf_dir/$sh".".OUT")or die "ERROR $!"; my $line; open (SH, "$cf_dir/$sh") or die "ERROR $!"; while ($line = <SH>){ if ( $line =~ /!bgs/){ $line =~ m/'syslogd'\)/; my $newline = $. + 3; $newline = $bgs; print OUT "$newline\n"; next; } elsif ($line =~ m/$agent/){ $line = $collect; next; } elsif ( $line =~ m/best1collect/) { $line = $collect; next; } elsif ($line =~ m/'syslogd'\)/){ my $newline = $. + 3; $newline = $bgs; print OUT "$newline\n"; } } continue { print OUT $line; #print $line; } } I'm trying to test to see if bgs is in the file. if it is not. I add the here document $bgs above syslogd. But, if it is there. It adds the $here document anyway. I just want it to change one thing and go on to the next file. 'bgs') /usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1collect + -q>>$LOG 2>>$LOG ;; 'syslogd') If the line is there it changes it. But, it also adds the here $bgs t +oo. Any thoughts appreciated. Thanks, Bill
In reply to I just want IF, OR, OR not every one by wcj75019
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |