my %params = $r->method eq 'POST' ? $r->content : $r->args; while ( my ( $key, $value ) = each %params ) { if ( "some reg-exp that is true if there is an upload" ) { print STDERR "value=$value\n"; my $tempfile = $value; #some fiddling with the $tempfile my $buffer; print STDERR "tempfile=$tempfile\n"; open( *OUTFILE,">>/tmp/myb.$tempfile") || die "couldn't open outfile: $!"; while ( read( $value, $buffer, 1024 ) ) { print OUTFILE $buffer; } close( *OUTFILE ); } }