in reply to Regex returns match the first time. It returns everything thereafter

You're better off not using the flip-flop operator, but something like this might work:

for my $server (@ARGV) { print "getting cgrpfile from $server\n"; my @ssh = `ssh $server /bin/cat $usrallow `; for (@ssh, '') { if (/^custom/ .. /^\z/) { print; } } }
  • Comment on Re: Regex returns match the first time. It returns everything thereafter
  • Download Code

Replies are listed 'Best First'.
Re^2: Regex returns match the first time. It returns everything thereafter
by LanX (Saint) on Nov 16, 2013 at 00:40 UTC
    Nope, any empty line will match '/^\z/' and stop the flip-flop.

    There is no end-of-array test possible in a foreach-loop, so no useful flop-condition.

    Using a flip-flop here is nonsense.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      Hi Rolf,
      What would you suggest I use?

        Something like this should work:

        my $found=0; print grep { $found or ( /line/ and $found=1 )} @ssh;

        Aaron B.
        Available for small or large Perl jobs and *nix system administration; see my home node.