# from Rich Shepard
# on Monday 13 July 2009 15:26:
> Does anyone have a working script that will count chunks of text
> separated by two newlines?
perl -e 'local $/ = "\n\n"; my @p = <>; print scalar(@p), "\n";'
You may want to check for blank paragraphs or allow for trailing,
ending, or more than two newlines. If you don't care about the
paragraph content, just counting those conditions would be like:
1+scalar(() = $t =~ m/(?!^)(\n\n+)(?!$)/mg)'
--Eric
--
"It works better if you plug it in!"
--Sattinger's Law
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug