in reply to Warning counter

Would
open(F, $variable) or warn "$variable: $! (" . $counter++ . ")\n";
do what you want? I left off the "Can not open" part because the error message in $! is almost always sufficient without adding extra verbiage.

Note that you're setting yourself up for another problem. Unless you're using $counter to decide whether F is really open, you'll get an error downstream when you try to read or write using F.