The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Decode::Source - Run scripts written in encodings other than utf-8


    use Decode::Source "iso-8859-1";
       ... code written in ISO-8859-1 ...
    use Decode::Source "cp-850";
       ... code written in DOS codepage 850 ...
    no Decode::Source;
        ... code written in US-ASCII ...


Use alternative encodings/charsets for your program code. Perl 5.8 or higher is required for use of this module.


This code is so far only tested on Win32 platforms!

Decode::Source makes it possible to write perl programs in any script or encoding supported by the Encode module. Variable names can contain non-ASCII characters, just as when you use the use utf8 pragma. All theese characters, both in identifiers and string literals, will be decoded to perl's internal utf-8 form, before execution.

The syntax are similar to use utf8 and no utf8, but Decode::Source also takes an optional argument with source encoding. This argument can be any argument that Encode's decode function accept as a valid encoding. See also Encode.


  use Decode::Source "windows-1252";
  $åke   = ["Åke Braun", "08-555 55 55"];
  $örjan = ["Örjan Älg", "08-555 55 54"];

  binmode STDOUT, ":encodings(cp850)";
  printf "Name: %-20s   Phone: %12s\n", @$_ for $åke, $örjan;


Encode, Encode::Supported, utf8


Magnus Håkansson, <>


Copyright 2003 by Magnus Håkansson

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 74:

Non-ASCII character seen before =encoding in '$åke'. Assuming CP1252