I want to extract the paragraphs from a text variable that retrieved from the DB.
for extracting the pargaphs from file handler i use the below code :
local $/ = undef;
@paragarphs =<STDIN>
what is the best option to extract paragraphs from a text variable using perl and if there are module on cpan that do this type of task ?
You’re almost there. Setting
$/toundefwill slurp in the entire text in one go.What you want is
local $/ = "";to enable paragraph mode, as perperldoc perlvar(emphasis my own):Of course, it is possible to get a filehandle to read from a string instead of a file:
Output