in reply to Re: Writing to a different file name
in thread Writing to a different file name

The open FOO, ">$file" syntax will not allow pipes, so there is no danger from "rm -rf / |".

It will get messed up if $file starts with & or >, though. To prevent this, just switching to 3-arg open is sufficient: open FOO, ">", $file or bailout("error opening output file: $!")