in reply to Re: Re: How to collect the stdout of a subroutine call?
in thread How to collect the stdout of a subroutine call?

You must use the return statement inside your subroutine. I am not sure I understand exactly what you are trying to do from reading your code, but I am assuming you want everything you are printing to be returned (Update and not printed). In that case you need to put the data in the variable first, then return it. Like this.... (code not tested)

my $output; foreach my $item (sort keys %seen) { $output .= "$item:<br>\n"; $output .= "\tLog in activity: ", $seen{$item}, "<br>\n"; foreach my $type (sort keys %{$typeseen{$item}}) { $output .= "\t", $type, " activity: ", $typeseen{$item}{$type}, "< +br>\n"; } return $output; }

Replies are listed 'Best First'.
Re: Re: Re: Re: How to collect the stdout of a subroutine call?
by Anonymous Monk on Apr 19, 2004 at 19:25 UTC
    It is a good idea but it doesn't work....

      If you explain the problem you had with it then maybe we can provide an answer that will better suit your needs. Just saying it didn't work is not descriptive enough.

      Are there any errors? Or just unexpected results? Have you put "use strict;" and "use warnings;" at the top of your script? Not that every script must have it, but I would put it in there at least while trying to solve this problem.

Re: Re: Re: Re: How to collect the stdout of a subroutine call?
by Anonymous Monk on Apr 19, 2004 at 19:36 UTC
    Ok, but it still doesn't work....
      Ok, but you still didn't tell us what happened...