Not neato, not handy.
There are already a lot of modules that handle files in lots of ways. And Perl's internal open function is not too bad either (since the three-argument form was invented, that is).
You don't need to use FileHandle to automatically assign a file handle. In recent Perls, you can just use a scalar to do so:
use Carp;
sub simpleopen {
my ($mode, $file) = @_;
my $fh;
open($fh, $mode, $file) or croak $!;
return $fh
}
my $logfile = simpleopen('>>', "$0.log");
And still, that's code I wouldn't use, because there's already a perfect OO solution to that:
IO::File.
use IO::File;
my $logfile = IO::File->new("$0.log", 'a');
I wonder why you used custom letters (qw/R W O F/), where the rest of the world uses qw/r a w/ and r+/w+/a+ (or even rw).
You might like to know the
qw// operator, that acts like
split ' ':
%i = qw(R < W >> O +> F +<);.
Last, I'd like to tell you to (I would force you, if I could) read
perlstyle. Indent! Add whitespace after commas! Indent some more!
2;0 juerd@ouranos:~$ perl -e'undef christmas'
Segmentation fault
2;139 juerd@ouranos:~$