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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.