on Mon, 13 May 2002 20:16:08 GMT, [EMAIL PROTECTED] (Shaun Fryer)
wrote: 

> I'm curious if anyone has an better idea of how to recieve
> multiple lines of <STDIN> into a single array. 
> [...]
> sub PromptForBody {
>   print ': ';
>   $thisLine = <STDIN>;
>   unless ($thisLine eq ".\n") {
>     push(@messageBody,$thisLine);
>     &PromptForBody;
>   }
> }
> 

I would do it like this:

    #! perl -w
    use strict;

    my @messageBody = ();

    print ': ';
    while (defined(my $thisLine = <STDIN>)) {
        last if $thisLine eq ".\n";
        push(@messageBody,$thisLine);
        print ': ';
    }
        
    print "You typed:\n";
    print foreach @messageBody;

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to