On 2/12/06, Ron Smith <[EMAIL PROTECTED]> wrote:

>   How would I redirect the output of the print line to an array instaed of 
> STDOUT?
>
>   my $firstBar = 5;
>   print "*" while $firstBar, $firstBar--;

You would write some Perl code that puts something into an array, and
you would use that in place of the print statement. (And what's with
that conditional? Did you mean to use the scalar comma operator?) I'm
not sure, but you may want something like this:

    push @data, "*" while $firstBar--;

But it occurs to me that you may be saying that you've already got a
program with print statements scattered throughout, and you want those
print statements to magically chuck the output data into an array (of
lines? of characters?). This could be done with a tied filehandle.
Have you looked for a module on CPAN?

    http://search.cpan.org/

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to