in reply to Multi-Line Input

One way (certainly not the only way) to do it is to put your input routine in a loop: (warning, drylabbed code follows)
my $answer; print "Enter your text: (type END to exit)\n"; while (<STDIN>) { last if /^END$/; $answer .= $_; }

Replies are listed 'Best First'.
Re^2: Multi-Line Input
by johngg (Canon) on Sep 23, 2009 at 22:02 UTC

    The problem is finding something to terminate your input that will not legitimately occur in that input. You can use BrowserUk's suggestion of ^Z/^D in an endless version of your while loop, breaking out with a test for eof.

    use strict; use warnings; my $prompt = q{Add input (CTRL-D to finish) : }; my @input = (); print $prompt; while( 1 ) { last if eof STDIN; push @input, scalar <STDIN>; print $prompt; } print qq{\n}; chomp @input; print qq{Your input:\n}, do { local $" = qq{\n -->}; qq{ -->@input}; }, qq{\n};

    Running it (the terminating ^D does not show up)

    knoppix@Knoppix:~/perl/Monks$ ./spw796843 Add input (CTRL-D to finish) : This is Add input (CTRL-D to finish) : a few words Add input (CTRL-D to finish) : of nonsense Add input (CTRL-D to finish) : Add input (CTRL-D to finish) : including a Add input (CTRL-D to finish) : blank line Add input (CTRL-D to finish) : Your input: -->This is -->a few words -->of nonsense --> -->including a -->blank line knoppix@Knoppix:~/perl/Monks$

    I usually tidy up the last prompt and the ^D (which, IIRC, does appear on Solaris) with the following change to the code.

    I hope this is of interest.

    Cheers,

    JohnGG