Tests whether the file is empty before opening it for writing.
#!/usr/local/bin/perl if (-e "outfile") { if (!(-w "outfile")) { die ("Missing write permission for outfile.\n"); } if (!(-z "outfile")) { die ("File outfile is non-empty.\n"); } }