in reply to Re: if or die!
in thread if or die!

Dear Shmem, I like that. It is simple. Thanks.
#!/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/scripts/best1collect -q>>\$LOG 2>>\$LOG\n" +; my $cf_dir = "/root/sysedge/cf_files"; #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) { local $/ = ''; # slurp mode open IN, '<', $sh # really? or is it "$cf_dir/$sh" ? or die "Can't open '$sh' for input: $!\n"; open OUT, '>', "$cf_dir/$sh.tmp" or die "Can't write '$cf_dir/$sh.tmp': $!\n"; $_ = <IN>; s/^\s*'bgs'\).*?;;//msg; s/^(\s*'syslogd'\).*?;;/$1\n$bgs/ms; print OUT; close OUT or die "Can't close filehandle OUT properly: $!\n"; rename "$cf_dir/$sh.tmp", $sh; # if appropriate }

Replies are listed 'Best First'.
Re^3: if or die!
by shmem (Chancellor) on Mar 02, 2008 at 17:59 UTC
    Unmatched ( in regex; marked by <-- HERE in m/^( <-- HERE \s*'syslogd'\).*?;;/ at b.t line 27

    Yeah, closing paren missing. Oops :-)

    s/^(\s*'syslogd'\).*?;;)/$1\n$bgs/ms; # missing here --------^

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re^3: if or die!
by ww (Archbishop) on Mar 02, 2008 at 18:06 UTC
    Update See shmem's note (it's not the escaped paren): It means that you have escaped the closing paren of your capture... as did shmem... and thus have an open paren without a close.

    Please, please: learn to proofread your code, rather than merely asking for that which you then cargo-cult. And please read the relevant documents or texts.

      "Cargo Cult"...I didn't think anyone else had ever read that from Feynman!

      Love it!

      UPDATE: It's one of my all-time favorite stories,

      UPDATE (again): Sorry...really messed up the tags.

      ack Albuquerque, NM
    A reply falls below the community's threshold of quality. You may see it by logging in.