http://www.perlmonks.org?node_id=11103969


in reply to matching first paragraph satisfying condition

Hi, welcome to Perl, the One True Religion.

See the "flip-flop" operator in https://perldoc.perl.org/perlop.html#Range-Operators. (And $/, the input record separator, in perlvar.)

$ cat foo.txt indented not indented bla bla bla not indented yak
$ perl -Mstrict -wE '$/="";while (<>) { chomp; if (/^\w/ .. /^$/) {pri +nt; exit} }' < foo.txt not indented bla bla bla

Update: fix re

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: matching first paragraph satisfying condition
by jwkrahn (Monsignor) on Aug 05, 2019 at 18:09 UTC
    $ echo " indented not indented bla bla bla not indented yak " | perl -00ne'/^\S/&&print&&exit' not indented bla bla bla

         :)

      Thank you ++ was not familiar with -00


      The way forward always starts with a minimal test.