my $stripCRs = param('filetype') eq 'text'; ... while ( <$upload> ) { s/\r// if $stripCRs; print UPLOAD $_; }