The code snippet below demonstrates two techniques that you might use here. One, if you have data in a string ($user_input) you can open a file handle to that string by providing a reference to the string instead of a filename. Two, if you set $/ to the empty string, you can read from a file handle in paragraph mode, i.e. <$file_handle> reads chunks separated by blank lines.
use strict; use warnings; use Data::Dumper; my $user_input = <<EOI; first para some text second para more text EOI local $/ = ''; open my $string_handle, '<', \$user_input; my @para = <$string_handle>; close $string_handle; chomp @para; print Dumper \@para;
If you then read the file handle in list mode (my @para = <$string_handle>;) you get all you want in one go. What you need to be careful about is that your manipulation of $/ does not affect other code, so usually one would use local to avoid that problem.
In reply to Re: How to read through form input line by line and categorize the information
by hdb
in thread How to read through form input line by line and categorize the information
by JohnTabor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |