in reply to Re^2: Output in variable
in thread Output in variable

Uhm, you already have the output in a variable. The variable is called $_. If you don't want to print it, then, well, perhaps you should consider not asking perl to print it.

Replies are listed 'Best First'.
Re^4: Output in variable
by Anonymous Monk on Jan 23, 2009 at 10:32 UTC
    Just use concatenation if you want to capture all the lines.
    my $output; $PatternToMatch="^SELECT"; $tmpfile="pattern.txt"; open(MYFILE, "$tmpfile")|| die "Cannot create $tmpfile\n"; while (<MYFILE>) { if (/$PatternToMatch/) { #print "$_"; $output .=$_; } }