shlomif has asked for the wisdom of the Perl Monks concerning the following question:
In perl-5.8.x the binmode built-in (and "open") have added more Unicode-related layers like ":utf8" or ":encoding(iso-8859-1)". However, they are completly unavailable and throw an exception in perl-5.6.x. I'm looking for a way to replace or emulate their behaviour in perl-5.6.x.
Specifically, in XML-RSS-1.30, we have the following code:
sub save { my ($self, $file) = @_; open(OUT, ">:encoding($self->{encoding})", "$file") or croak "Cannot open file $file for write: $!"; print OUT $self->as_string; close OUT; }
Assuming we want the contents of $self->as_string() to be stored in the file using the encoding $self->{encoding}, what should we do in perl-5.6.x instead? Will Encode.pm be of any help?
We'll probably keep the code for perl-5.8.x as is, but also add some workarounds for perl-5.6.x.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing perl-5.8.x's filehandle "layers" in perl-5.6.x
by ikegami (Patriarch) on Jun 25, 2007 at 14:38 UTC | |
by shlomif (Beadle) on Jun 25, 2007 at 17:11 UTC |