Perl to output processed XML file encoded as UTF-8 with UNIX line endings (in Win32 environment)?

Posted by Umber Ferrule on Stack Overflow See other posts from Stack Overflow or by Umber Ferrule
Published on 2010-04-30T11:59:46Z Indexed on 2010/04/30 12:27 UTC
Read the original article Hit count: 254

Filed under:
|
|
|
|

Running ActiveState Perl 5.8.8 on WinXP.

As the title suggests, I'd like to output an XML file as UTF-8 with UNIX line endings.

I've looked at the PerlDoc for binmode, but am unsure of the exact syntax (if I'm not barking up the wrong tree). The following doesn't do it (forgive my Perl - it's a learning process!):

sub SaveFile
{
    my($FileName, $Contents) = @_;

    my $File = "SAVE";
    unless( open($File, ">:utf-8 :unix", $FileName) )
    {
        die("Cannot open $FileName");
    }
    print $File @$Contents;

    close($File);
}

Any suggestions? Thanks.

© Stack Overflow or respective owner

Related posts about perl

Related posts about file