# phpman > info > open

[XDG-OPEN(1)](https://www.chedong.com/phpMan.php/man/XDG-OPEN/1/markdown)                     xdg-open Manual                    [XDG-OPEN(1)](https://www.chedong.com/phpMan.php/man/XDG-OPEN/1/markdown)

NAME
       xdg-open - opens a file or URL in the user's preferred application

SYNOPSIS
       xdg-open {file | URL}

       xdg-open {--help | --manual | --version}

DESCRIPTION
       xdg-open opens a file or URL in the user's preferred application. If a
       URL is provided the URL will be opened in the user's preferred web
       browser. If a file is provided the file will be opened in the preferred
       application for files of that type. xdg-open supports file, ftp, http
       and https URLs.

       xdg-open is for use inside a desktop session only. It is not
       recommended to use xdg-open as root.

OPTIONS
       --help
           Show command synopsis.

       --manual
           Show this manual page.

       --version
           Show the xdg-utils version information.

EXIT CODES
       An exit code of 0 indicates success while a non-zero exit code
       indicates failure. The following failure codes can be returned:

       1
           Error in command line syntax.

       2
           One of the files passed on the command line did not exist.

       3
           A required tool could not be found.

       4
           The action failed.

SEE ALSO
       [xdg-mime(1)](https://www.chedong.com/phpMan.php/man/xdg-mime/1/markdown), [xdg-settings(1)](https://www.chedong.com/phpMan.php/man/xdg-settings/1/markdown), MIME applications associations
       specification[1]

EXAMPLES
           xdg-open '<http://www.freedesktop.org/>'

       Opens the freedesktop.org website in the user's default browser.

           xdg-open /tmp/foobar.png

       Opens the PNG image file /tmp/foobar.png in the user's default image
       viewing application.

AUTHORS
       Kevin Krammer
           Author.

       Jeremy White
           Author.

COPYRIGHT
       Copyright (C) 2006

NOTES
        1. MIME applications associations specification
           <http://www.freedesktop.org/wiki/Specifications/mime-apps-spec/>

xdg-utils 1.0                     08/22/2022                       [XDG-OPEN(1)](https://www.chedong.com/phpMan.php/man/XDG-OPEN/1/markdown)
[open(3perl)](https://www.chedong.com/phpMan.php/man/open/3perl/markdown)            Perl Programmers Reference Guide            [open(3perl)](https://www.chedong.com/phpMan.php/man/open/3perl/markdown)

NAME
       open - perl pragma to set default PerlIO layers for input and output

SYNOPSIS
           use open IN  => ':crlf', OUT => ':raw';
           open my $in, '<', 'foo.txt' or die "open failed: $!";
           my $line = <$in>; # CRLF translated
           close $in;
           open my $out, '>', 'bar.txt' or die "open failed: $!";
           print $out $line; # no translation of bytes
           close $out;

           use open OUT => ':encoding(UTF-8)';
           use open IN  => ':encoding(iso-8859-7)';

           use open IO  => ':locale';

           # IO implicit only for :utf8, :encoding, :locale
           use open ':encoding(UTF-8)';
           use open ':encoding(iso-8859-7)';
           use open ':locale';

           # with :std, also affect global standard handles
           use open ':std', ':encoding(UTF-8)';
           use open ':std', OUT => ':encoding(cp1252)';
           use open ':std', IO => ':raw :encoding(UTF-16LE)';

DESCRIPTION
       Full-fledged support for I/O layers is now implemented provided Perl is
       configured to use PerlIO as its IO system (which has been the default
       since 5.8, and the only supported configuration since 5.16).

       The "open" pragma serves as one of the interfaces to declare default
       "layers" (previously known as "disciplines") for all I/O. Any open(),
       readpipe() (aka qx//) and similar operators found within the lexical
       scope of this pragma will use the declared defaults via the "${^OPEN}"
       variable.

       Layers are specified with a leading colon by convention. You can
       specify a stack of multiple layers as a space-separated string.  See
       PerlIO for more information on the available layers.

       With the "IN" subpragma you can declare the default layers of input
       streams, and with the "OUT" subpragma you can declare the default
       layers of output streams.  With the "IO" subpragma (may be omitted for
       ":utf8", ":locale", or ":encoding") you can control both input and
       output streams simultaneously.

       When open() is given an explicit list of layers (with the three-arg
       syntax), they override the list declared using this pragma.  open() can
       also be given a single colon (:) for a layer name, to override this
       pragma and use the default as detailed in "Defaults and how to override
       them" in PerlIO.

       To translate from and to an arbitrary text encoding, use the
       ":encoding" layer.  The matching of encoding names in ":encoding" is
       loose: case does not matter, and many encodings have several aliases.
       See [Encode::Supported](https://www.chedong.com/phpMan.php/perldoc/Encode%3A%3ASupported/markdown) for details and the list of supported locales.

       If you want to set your encoding layers based on your locale
       environment variables, you can use the ":locale" pseudo-layer.  For
       example:

           $ENV{LANG} = 'ru_RU.KOI8-R';
           # the :locale will probe the locale environment variables like LANG
           use open OUT => ':locale';
           open(my $out, '>', 'koi8') or die "open failed: $!";
           print $out [chr(0x430)](https://www.chedong.com/phpMan.php/man/chr/0x430/markdown); # CYRILLIC SMALL LETTER A = KOI8-R 0xc1
           close $out;
           open(my $in, '<', 'koi8') or die "open failed: $!";
           printf "%#x\n", ord(<$in>); # this should print 0xc1
           close $in;

       The logic of ":locale" is described in full in "The ":locale" sub-
       pragma" in encoding, but in short it is first trying
       nl_langinfo(CODESET) and then guessing from the LC_ALL and LANG locale
       environment variables.  ":locale" also implicitly turns on ":std".

       ":std" is not a layer but an additional subpragma.  When specified in
       the import list, it activates an additional functionality of pushing
       the layers selected for input/output handles to the standard
       filehandles (STDIN, STDOUT, STDERR).  If the new layers and existing
       layer stack both end with an ":encoding" layer, the existing
       ":encoding" layer will also be removed.

       For example, if both input and out are chosen to be ":encoding(UTF-8)",
       a ":std" will mean that STDIN, STDOUT, and STDERR will also have
       ":encoding(UTF-8)" set.  On the other hand, if only output is chosen to
       be in ":encoding(koi8r)", a ":std" will cause only the STDOUT and
       STDERR to be in "koi8r".

       The effect of ":std" is not lexical as it modifies the layer stack of
       the global handles.  If you wish to apply only this global effect and
       not the effect on handles that are opened in that scope, you can
       isolate the call to this pragma in its own lexical scope.

           { use open ':std', IO => ':encoding(UTF-8)' }

IMPLEMENTATION DETAILS
       There is a class method in "[PerlIO::Layer](https://www.chedong.com/phpMan.php/perldoc/PerlIO%3A%3ALayer/markdown)" "find" which is implemented
       as XS code.  It is called by "import" to validate the layers:

          [PerlIO::Layer](https://www.chedong.com/phpMan.php/perldoc/PerlIO%3A%3ALayer/markdown)::->find("perlio")

       The return value (if defined) is a Perl object, of class
       "[PerlIO::Layer](https://www.chedong.com/phpMan.php/perldoc/PerlIO%3A%3ALayer/markdown)" which is created by the C code in perlio.c.  As yet
       there is nothing useful you can do with the object at the perl level.

SEE ALSO
       "binmode" in perlfunc, "open" in perlfunc, perlunicode, PerlIO,
       encoding

perl v5.34.0                      2025-07-25                       [open(3perl)](https://www.chedong.com/phpMan.php/man/open/3perl/markdown)
