Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

matching first paragraph satisfying condition

by mnshptl32 (Initiate)
on Aug 05, 2019 at 16:14 UTC ( #11103963=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    awk -v RS='' -v ORS='\n\n' '/^[^ ].*$/' file.txt | awk -v RS='' 'NR==1
    +{print $0}'
    
  2. or download this
    perl -0pe 's/.*?\n*?([^ \n].*?)\n\n.*/$1/gs' file.txt
    
  3. or download this
    perl -0pe 's/([^ \n].*?)\n\n.*/$1/gs' file.txt
    
  4. or download this
    perl -0pe 's/.*?\n([^ \n].*?)\n\n.*/$1/gs' file.txt
    
  5. or download this
    if ( $. == 1 and /^[^ ].*$/ ) {...}
    
  6. or download this
    echo '' > tempfile.txt ; cat file.txt >> tempfile.txt ; perl ...
    
  7. or download this
    if [[ $(egrep -n -m1 -e '^[^ ]' file.txt | sed 's/^\([0-9]\+\):.*/\1/g
    +') -eq 1 ]] ; then perl ... ; else perl ... ; fi
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11103963]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2020-01-21 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?