my $filename = "testfile.txt"; { open FH, "<$filename" or ( open FH, ">$filename" and close FH and redo ) or die "Bleah!\n$!"; }