#!/usr/local/bin/perl -w # ^^ delete this if you only have perl4 # Extract the "EXAMPLES" part of an R help file -- # ---- ----- Martin Maechler ) { s/^\n+//; ##--- At this stage, each "line" starts with "KEYWORD(" and ends with ")" ##--> could also extract others.. # Show what we have now (for DEBUGGING): # s/\n/«»/g; print STDERR "$.:\t|$_\n"; next line unless /$Pat/; #Dbg: print "\n\n___FOUND___ $.:\t|$_\n"; do { $some = 1; print "\n" } unless $some; s/${Pat}\n//; s/\)$//; s/\nBLANK\s*\n/\n\n/g; print; } print "---- NO Example yet... \n" unless $some;