We can probably give you better help if you tell us why you want to do this. However the following may be of use:
use strict; use warnings; my $file = <<FILE; firstchance: Is there a method that will allow me to easly split a fil +e into multiple files by blank line as seperator. Perhaps a module th +at will make it easy firstchance: can perl create virtual files for this process with the h +elp of CPAN tye: $/, 'paragraph mode' ? Any advances? ;> FILE open my $in, '<', \$file; local $/ = "\n\n"; my @parts = <$in>; chomp @parts; print "----------\n$_\n" for @parts;
Prints:
---------- firstchance: Is there a method that will allow me to easly split a fil +e into multiple files by blank line as seperator. Perhaps a module th +at will make it easy ---------- firstchance: can perl create virtual files for this process with the h +elp of CPAN ---------- tye: , 'paragraph mode' ? ---------- Any advances? ---------- ;>
Note the use of an "in memory" file using $file (as suggested by CountZero) and the use of the special variable $/ to read blank line separated blocks as records (as suggested by tye).
In reply to Re: splitting files into multiple sections to be processed as a file
by GrandFather
in thread splitting files into multiple sections to be processed as a file
by firstchance
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |