Krang::IO - abstract away any IO operations that need to be Charset-aware
my $FH;
# for writing
pkg('IO')->open($FH, '>', '/some/file')
or die "Could not open for writing: $!";
# for reading
pkg('IO')->open($FH, '<', '/some/file')
or die "Could not open for reading: $!";
# get an IO::File object with the right encoding
my $io = pkg('IO')->io_file(">/some/file");
Krang can be setup to run on multiple character sets. A lot of the common character sets don't need anything really special to interact with the files but some (like UTF-8) do.
This module provides the necessary abstraction so that for the most part you don't need to worry about that.
This works like Perl's built-in open (the 3 argument version), but will set the appropriate encoding based on the Charset.
my $FH;
# for writing
pkg('IO')->open($FH, '>', '/some/file')
or die "Could not open for writing: $!";
This returns a new IO::File object and acts just like single
arg form of IO::File::new().
my $io = pkg('IO')->io_file(">/some/file");