CINXE.COM
perlapio - perl's IO abstraction interface. - Perldoc Browser
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>perlapio - perl's IO abstraction interface. - Perldoc Browser</title> <link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser"> <link rel="canonical" href="https://perldoc.perl.org/perlapio"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" /> <style> body { background: #f4f4f5; color: #020202; } .navbar-dark { background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%); background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%); background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0); background-repeat: repeat-x; } .navbar-dark .navbar-nav .nav-link, .navbar-dark .navbar-nav .nav-link:focus { color: #fff } .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 } #wrapperlicious { margin: 0 auto; font: 0.9em 'Helvetica Neue', Helvetica, sans-serif; font-weight: normal; line-height: 1.5em; margin: 0; padding: 0; } #wrapperlicious h1 { font-size: 1.5em } #wrapperlicious h2 { font-size: 1.3em } #wrapperlicious h3 { font-size: 1.1em } #wrapperlicious h4 { font-size: 0.9em } #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3, #wrapperlicious h4, #wrapperlicious dt { color: #020202; margin-top: 1em; margin-bottom: 1em; position: relative; font-weight: bold; } #wrapperlicious a { color: inherit; text-decoration: underline } #wrapperlicious #toc { text-decoration: none } #wrapperlicious a:hover { color: #2a2a2a } #wrapperlicious a img { border: 0 } #wrapperlicious :not(pre) > code { color: inherit; background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; font: 0.9em Consolas, Menlo, Monaco, monospace; padding: 0.3em; } #wrapperlicious dd { margin: 0; margin-left: 2em; } #wrapperlicious dt { color: #2a2a2a; font-weight: bold; margin-left: 0.9em; } #wrapperlicious p { margin-bottom: 1em; margin-top: 1em; } #wrapperlicious li > p { margin-bottom: 0; margin-top: 0; } #wrapperlicious pre { border: 1px solid #c1c1c1; border-radius: 3px; font: 100% Consolas, Menlo, Monaco, monospace; margin-bottom: 1em; margin-top: 1em; } #wrapperlicious pre > code { display: block; background-color: #f6f6f6; font: 0.9em Consolas, Menlo, Monaco, monospace; line-height: 1.5em; text-align: left; white-space: pre; padding: 1em; } #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul { margin-bottom: 1em; margin-top: 1em; } #wrapperlicious ul { list-style-type: square; } #wrapperlicious ul ul { margin-bottom: 0px; margin-top: 0px; } #footer { font-size: 0.8em; padding-top: 0.5em; text-align: center; } #more { display: inline; font-size: 0.8em; } #perldocdiv { background-color: #fff; border: 1px solid #c1c1c1; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; margin-left: auto; margin-right: auto; padding: 3em; padding-top: 1em; max-width: 960px; } #moduleversion { float: right } #wrapperlicious .leading-notice { font-style: italic; padding-left: 1em; margin-top: 1em; margin-bottom: 1em; } #wrapperlicious .permalink { display: none; left: -0.75em; position: absolute; padding-right: 0.25em; text-decoration: none; } #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink, #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink, #wrapperlicious dt:hover .permalink { display: block; } </style> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-KVNWBNT5FB'); gtag('config', 'UA-50555-3'); </script> </head> <body> <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <a class="navbar-brand" href="/"><img src="/images/perl_camel_30.png" width="30" height="30" class="d-inline-block align-top" alt="Perl Camel Logo"> Perldoc Browser</a> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav mr-auto"> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.005</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-stable"> <a class="dropdown-item" href="/perlapio">Latest</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1/perlapio">5.40.1</a> <a class="dropdown-item" href="/5.40.0/perlapio">5.40.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3/perlapio">5.38.3</a> <a class="dropdown-item" href="/5.38.2/perlapio">5.38.2</a> <a class="dropdown-item" href="/5.38.1/perlapio">5.38.1</a> <a class="dropdown-item" href="/5.38.0/perlapio">5.38.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.36.3/perlapio">5.36.3</a> <a class="dropdown-item" href="/5.36.2/perlapio">5.36.2</a> <a class="dropdown-item" href="/5.36.1/perlapio">5.36.1</a> <a class="dropdown-item" href="/5.36.0/perlapio">5.36.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.34.3/perlapio">5.34.3</a> <a class="dropdown-item" href="/5.34.2/perlapio">5.34.2</a> <a class="dropdown-item" href="/5.34.1/perlapio">5.34.1</a> <a class="dropdown-item" href="/5.34.0/perlapio">5.34.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.32.1/perlapio">5.32.1</a> <a class="dropdown-item" href="/5.32.0/perlapio">5.32.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.30.3/perlapio">5.30.3</a> <a class="dropdown-item" href="/5.30.2/perlapio">5.30.2</a> <a class="dropdown-item" href="/5.30.1/perlapio">5.30.1</a> <a class="dropdown-item" href="/5.30.0/perlapio">5.30.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.28.3/perlapio">5.28.3</a> <a class="dropdown-item" href="/5.28.2/perlapio">5.28.2</a> <a class="dropdown-item" href="/5.28.1/perlapio">5.28.1</a> <a class="dropdown-item" href="/5.28.0/perlapio">5.28.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.26.3/perlapio">5.26.3</a> <a class="dropdown-item" href="/5.26.2/perlapio">5.26.2</a> <a class="dropdown-item" href="/5.26.1/perlapio">5.26.1</a> <a class="dropdown-item" href="/5.26.0/perlapio">5.26.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.24.4/perlapio">5.24.4</a> <a class="dropdown-item" href="/5.24.3/perlapio">5.24.3</a> <a class="dropdown-item" href="/5.24.2/perlapio">5.24.2</a> <a class="dropdown-item" href="/5.24.1/perlapio">5.24.1</a> <a class="dropdown-item" href="/5.24.0/perlapio">5.24.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.22.4/perlapio">5.22.4</a> <a class="dropdown-item" href="/5.22.3/perlapio">5.22.3</a> <a class="dropdown-item" href="/5.22.2/perlapio">5.22.2</a> <a class="dropdown-item" href="/5.22.1/perlapio">5.22.1</a> <a class="dropdown-item" href="/5.22.0/perlapio">5.22.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.20.3/perlapio">5.20.3</a> <a class="dropdown-item" href="/5.20.2/perlapio">5.20.2</a> <a class="dropdown-item" href="/5.20.1/perlapio">5.20.1</a> <a class="dropdown-item" href="/5.20.0/perlapio">5.20.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/perlapio">5.18.4</a> <a class="dropdown-item" href="/5.18.3/perlapio">5.18.3</a> <a class="dropdown-item" href="/5.18.2/perlapio">5.18.2</a> <a class="dropdown-item" href="/5.18.1/perlapio">5.18.1</a> <a class="dropdown-item" href="/5.18.0/perlapio">5.18.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.16.3/perlapio">5.16.3</a> <a class="dropdown-item" href="/5.16.2/perlapio">5.16.2</a> <a class="dropdown-item" href="/5.16.1/perlapio">5.16.1</a> <a class="dropdown-item" href="/5.16.0/perlapio">5.16.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.14.4/perlapio">5.14.4</a> <a class="dropdown-item" href="/5.14.3/perlapio">5.14.3</a> <a class="dropdown-item" href="/5.14.2/perlapio">5.14.2</a> <a class="dropdown-item" href="/5.14.1/perlapio">5.14.1</a> <a class="dropdown-item" href="/5.14.0/perlapio">5.14.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.12.5/perlapio">5.12.5</a> <a class="dropdown-item" href="/5.12.4/perlapio">5.12.4</a> <a class="dropdown-item" href="/5.12.3/perlapio">5.12.3</a> <a class="dropdown-item" href="/5.12.2/perlapio">5.12.2</a> <a class="dropdown-item" href="/5.12.1/perlapio">5.12.1</a> <a class="dropdown-item" href="/5.12.0/perlapio">5.12.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.10.1/perlapio">5.10.1</a> <a class="dropdown-item" href="/5.10.0/perlapio">5.10.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.9/perlapio">5.8.9</a> <a class="dropdown-item" href="/5.8.8/perlapio">5.8.8</a> <a class="dropdown-item" href="/5.8.7/perlapio">5.8.7</a> <a class="dropdown-item" href="/5.8.6/perlapio">5.8.6</a> <a class="dropdown-item" href="/5.8.5/perlapio">5.8.5</a> <a class="dropdown-item" href="/5.8.4/perlapio">5.8.4</a> <a class="dropdown-item" href="/5.8.3/perlapio">5.8.3</a> <a class="dropdown-item" href="/5.8.2/perlapio">5.8.2</a> <a class="dropdown-item" href="/5.8.1/perlapio">5.8.1</a> <a class="dropdown-item" href="/5.8.0/perlapio">5.8.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.6.2/perlapio">5.6.2</a> <a class="dropdown-item" href="/5.6.1/perlapio">5.6.1</a> <a class="dropdown-item" href="/5.6.0/perlapio">5.6.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005_04/perlapio">5.005_04</a> <a class="dropdown-item" href="/5.005_03/perlapio">5.005_03</a> <a class="dropdown-item" href="/5.005_02/perlapio">5.005_02</a> <a class="dropdown-item" href="/5.005_01/perlapio">5.005_01</a> <a class="dropdown-item active" href="/5.005/perlapio">5.005</a> </div> </li> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-dev"> <a class="dropdown-item" href="/blead/perlapio">blead</a> <a class="dropdown-item" href="/5.41.10/perlapio">5.41.10</a> <a class="dropdown-item" href="/5.41.9/perlapio">5.41.9</a> <a class="dropdown-item" href="/5.41.8/perlapio">5.41.8</a> <a class="dropdown-item" href="/5.41.7/perlapio">5.41.7</a> <a class="dropdown-item" href="/5.41.6/perlapio">5.41.6</a> <a class="dropdown-item" href="/5.41.5/perlapio">5.41.5</a> <a class="dropdown-item" href="/5.41.4/perlapio">5.41.4</a> <a class="dropdown-item" href="/5.41.3/perlapio">5.41.3</a> <a class="dropdown-item" href="/5.41.2/perlapio">5.41.2</a> <a class="dropdown-item" href="/5.41.1/perlapio">5.41.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1-RC1/perlapio">5.40.1-RC1</a> <a class="dropdown-item" href="/5.40.0-RC2/perlapio">5.40.0-RC2</a> <a class="dropdown-item" href="/5.40.0-RC1/perlapio">5.40.0-RC1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.10/perlapio">5.39.10</a> <a class="dropdown-item" href="/5.39.9/perlapio">5.39.9</a> <a class="dropdown-item" href="/5.39.8/perlapio">5.39.8</a> <a class="dropdown-item" href="/5.39.7/perlapio">5.39.7</a> <a class="dropdown-item" href="/5.39.6/perlapio">5.39.6</a> <a class="dropdown-item" href="/5.39.5/perlapio">5.39.5</a> <a class="dropdown-item" href="/5.39.4/perlapio">5.39.4</a> <a class="dropdown-item" href="/5.39.3/perlapio">5.39.3</a> <a class="dropdown-item" href="/5.39.2/perlapio">5.39.2</a> <a class="dropdown-item" href="/5.39.1/perlapio">5.39.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3-RC1/perlapio">5.38.3-RC1</a> </div> </li> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-nav"> <a class="dropdown-item" href="/5.005/perl">Perl</a> <a class="dropdown-item" href="/5.005/perlintro">Intro</a> <a class="dropdown-item" href="/5.005/perl#Tutorials">Tutorials</a> <a class="dropdown-item" href="/5.005/perlfaq">FAQs</a> <a class="dropdown-item" href="/5.005/perl#Reference-Manual">Reference</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005/perlop">Operators</a> <a class="dropdown-item" href="/5.005/functions">Functions</a> <a class="dropdown-item" href="/5.005/variables">Variables</a> <a class="dropdown-item" href="/5.005/modules">Modules</a> <a class="dropdown-item" href="/5.005/perlutil">Utilities</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005/perldelta">Release Notes</a> <a class="dropdown-item" href="/5.005/perlcommunity">Community</a> <a class="dropdown-item" href="/5.005/perlhist">History</a> </div> </li> </ul> <ul class="navbar-nav"> <script> function set_expand (expand) { var perldocdiv = document.getElementById('perldocdiv'); var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width'); var expanded = (width == '' || width == 'none') ? true : false; if (expand === null) { expand = !expanded; } if ((expand && !expanded) || (!expand && expanded)) { perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px'); var button_classlist = document.getElementById('content-expand-button').classList; if (expand) { button_classlist.add('btn-light'); button_classlist.remove('btn-outline-light'); } else { button_classlist.add('btn-outline-light'); button_classlist.remove('btn-light'); } } return expand; } function toggle_expand () { var expand = set_expand(null); document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC'; } function read_expand () { return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function () { if (read_expand()) { set_expand(true); } }); } else if (read_expand()) { set_expand(true); } </script> <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-4" onclick="toggle_expand()">Expand</button> </ul> <form class="form-inline" method="get" action="/5.005/search"> <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search" value=""> </form> </div> </nav> <div id="wrapperlicious" class="container-fluid"> <div id="perldocdiv"> <div id="links"> <a href="/5.005/perlapio">perlapio</a> <div id="more"> (<a href="/5.005/perlapio.txt">source</a>, <a href="https://metacpan.org/pod/perlapio">CPAN</a>) </div> </div> <div class="leading-notice"> You are viewing the version of this documentation from Perl 5.005. <a href="/perlapio">View the latest version</a> </div> <h1><a id="toc">CONTENTS</a></h1> <ul> <li> <a class="text-decoration-none" href="#NAME">NAME</a> </li> <li> <a class="text-decoration-none" href="#SYNOPSIS">SYNOPSIS</a> </li> <li> <a class="text-decoration-none" href="#DESCRIPTION">DESCRIPTION</a> <ul> <li> <a class="text-decoration-none" href="#Co-existence-with-stdio">Co-existence with stdio</a> </li> </ul> </li> </ul> <h1 id="NAME"><a class="permalink" href="#NAME">#</a>NAME</h1> <p>perlapio - perl's IO abstraction interface.</p> <h1 id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">#</a>SYNOPSIS</h1> <pre><code>PerlIO *PerlIO_stdin(void); PerlIO *PerlIO_stdout(void); PerlIO *PerlIO_stderr(void); PerlIO *PerlIO_open(const char *,const char *); int PerlIO_close(PerlIO *); int PerlIO_stdoutf(const char *,...) int PerlIO_puts(PerlIO *,const char *); int PerlIO_putc(PerlIO *,int); int PerlIO_write(PerlIO *,const void *,size_t); int PerlIO_printf(PerlIO *, const char *,...); int PerlIO_vprintf(PerlIO *, const char *, va_list); int PerlIO_flush(PerlIO *); int PerlIO_eof(PerlIO *); int PerlIO_error(PerlIO *); void PerlIO_clearerr(PerlIO *); int PerlIO_getc(PerlIO *); int PerlIO_ungetc(PerlIO *,int); int PerlIO_read(PerlIO *,void *,size_t); int PerlIO_fileno(PerlIO *); PerlIO *PerlIO_fdopen(int, const char *); PerlIO *PerlIO_importFILE(FILE *, int flags); FILE *PerlIO_exportFILE(PerlIO *, int flags); FILE *PerlIO_findFILE(PerlIO *); void PerlIO_releaseFILE(PerlIO *,FILE *); void PerlIO_setlinebuf(PerlIO *); long PerlIO_tell(PerlIO *); int PerlIO_seek(PerlIO *,off_t,int); int PerlIO_getpos(PerlIO *,Fpos_t *) int PerlIO_setpos(PerlIO *,Fpos_t *) void PerlIO_rewind(PerlIO *); int PerlIO_has_base(PerlIO *); int PerlIO_has_cntptr(PerlIO *); int PerlIO_fast_gets(PerlIO *); int PerlIO_canset_cnt(PerlIO *); char *PerlIO_get_ptr(PerlIO *); int PerlIO_get_cnt(PerlIO *); void PerlIO_set_cnt(PerlIO *,int); void PerlIO_set_ptrcnt(PerlIO *,char *,int); char *PerlIO_get_base(PerlIO *); int PerlIO_get_bufsiz(PerlIO *);</code></pre> <h1 id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">#</a>DESCRIPTION</h1> <p>Perl's source code should use the above functions instead of those defined in ANSI C's <i>stdio.h</i>. The perl headers will <code>#define</code> them to the I/O mechanism selected at Configure time.</p> <p>The functions are modeled on those in <i>stdio.h</i>, but parameter order has been "tidied up a little".</p> <dl> <dt id="PerlIO-*"><a class="permalink" href="#PerlIO-*">#</a><a id="PerlIO"></a><b>PerlIO *</b></dt> <dd> <p>This takes the place of FILE *. Like FILE * it should be treated as opaque (it is probably safe to assume it is a pointer to something).</p> </dd> <dt id="PerlIO_stdin(),-PerlIO_stdout(),-PerlIO_stderr()"><a class="permalink" href="#PerlIO_stdin(),-PerlIO_stdout(),-PerlIO_stderr()">#</a><a id="PerlIO_stdin"></a><a id="PerlIO_stdin-PerlIO_stdout-PerlIO_stderr"></a><b>PerlIO_stdin()</b>, <b>PerlIO_stdout()</b>, <b>PerlIO_stderr()</b></dt> <dd> <p>Use these rather than <code>stdin</code>, <code>stdout</code>, <code>stderr</code>. They are written to look like "function calls" rather than variables because this makes it easier to <i>make them</i> function calls if platform cannot export data to loaded modules, or if (say) different "threads" might have different values.</p> </dd> <dt id="PerlIO_open(path,-mode),-PerlIO_fdopen(fd,mode)"><a class="permalink" href="#PerlIO_open(path,-mode),-PerlIO_fdopen(fd,mode)">#</a><a id="PerlIO_open"></a><a id="PerlIO_open-path-mode-PerlIO_fdopen-fd-mode"></a><b>PerlIO_open(path, mode)</b>, <b>PerlIO_fdopen(fd,mode)</b></dt> <dd> <p>These correspond to fopen()/fdopen() arguments are the same.</p> </dd> <dt id="PerlIO_printf(f,fmt,...),-PerlIO_vprintf(f,fmt,a)"><a class="permalink" href="#PerlIO_printf(f,fmt,...),-PerlIO_vprintf(f,fmt,a)">#</a><a id="PerlIO_printf"></a><a id="PerlIO_printf-f-fmt-...-PerlIO_vprintf-f-fmt-a"></a><b>PerlIO_printf(f,fmt,...)</b>, <b>PerlIO_vprintf(f,fmt,a)</b></dt> <dd> <p>These are fprintf()/vfprintf() equivalents.</p> </dd> <dt id="PerlIO_stdoutf(fmt,...)"><a class="permalink" href="#PerlIO_stdoutf(fmt,...)">#</a><a id="PerlIO_stdoutf"></a><a id="PerlIO_stdoutf-fmt"></a><b>PerlIO_stdoutf(fmt,...)</b></dt> <dd> <p>This is printf() equivalent. printf is #defined to this function, so it is (currently) legal to use <code>printf(fmt,...)</code> in perl sources.</p> </dd> <dt id="PerlIO_read(f,buf,count),-PerlIO_write(f,buf,count)"><a class="permalink" href="#PerlIO_read(f,buf,count),-PerlIO_write(f,buf,count)">#</a><a id="PerlIO_read"></a><a id="PerlIO_read-f-buf-count-PerlIO_write-f-buf-count"></a><b>PerlIO_read(f,buf,count)</b>, <b>PerlIO_write(f,buf,count)</b></dt> <dd> <p>These correspond to fread() and fwrite(). Note that arguments are different, there is only one "count" and order has "file" first.</p> </dd> <dt id="PerlIO_close(f)"><a class="permalink" href="#PerlIO_close(f)">#</a><a id="PerlIO_close"></a><a id="PerlIO_close-f"></a><b>PerlIO_close(f)</b></dt> <dd> </dd> <dt id="PerlIO_puts(f,s),-PerlIO_putc(f,c)"><a class="permalink" href="#PerlIO_puts(f,s),-PerlIO_putc(f,c)">#</a><a id="PerlIO_puts"></a><a id="PerlIO_puts-f-s-PerlIO_putc-f-c"></a><b>PerlIO_puts(f,s)</b>, <b>PerlIO_putc(f,c)</b></dt> <dd> <p>These correspond to fputs() and fputc(). Note that arguments have been revised to have "file" first.</p> </dd> <dt id="PerlIO_ungetc(f,c)"><a class="permalink" href="#PerlIO_ungetc(f,c)">#</a><a id="PerlIO_ungetc"></a><a id="PerlIO_ungetc-f-c"></a><b>PerlIO_ungetc(f,c)</b></dt> <dd> <p>This corresponds to ungetc(). Note that arguments have been revised to have "file" first.</p> </dd> <dt id="PerlIO_getc(f)"><a class="permalink" href="#PerlIO_getc(f)">#</a><a id="PerlIO_getc"></a><a id="PerlIO_getc-f"></a><b>PerlIO_getc(f)</b></dt> <dd> <p>This corresponds to getc().</p> </dd> <dt id="PerlIO_eof(f)"><a class="permalink" href="#PerlIO_eof(f)">#</a><a id="PerlIO_eof"></a><a id="PerlIO_eof-f"></a><b>PerlIO_eof(f)</b></dt> <dd> <p>This corresponds to feof().</p> </dd> <dt id="PerlIO_error(f)"><a class="permalink" href="#PerlIO_error(f)">#</a><a id="PerlIO_error"></a><a id="PerlIO_error-f"></a><b>PerlIO_error(f)</b></dt> <dd> <p>This corresponds to ferror().</p> </dd> <dt id="PerlIO_fileno(f)"><a class="permalink" href="#PerlIO_fileno(f)">#</a><a id="PerlIO_fileno"></a><a id="PerlIO_fileno-f"></a><b>PerlIO_fileno(f)</b></dt> <dd> <p>This corresponds to fileno(), note that on some platforms, the meaning of "fileno" may not match Unix.</p> </dd> <dt id="PerlIO_clearerr(f)"><a class="permalink" href="#PerlIO_clearerr(f)">#</a><a id="PerlIO_clearerr"></a><a id="PerlIO_clearerr-f"></a><b>PerlIO_clearerr(f)</b></dt> <dd> <p>This corresponds to clearerr(), i.e., clears 'eof' and 'error' flags for the "stream".</p> </dd> <dt id="PerlIO_flush(f)"><a class="permalink" href="#PerlIO_flush(f)">#</a><a id="PerlIO_flush"></a><a id="PerlIO_flush-f"></a><b>PerlIO_flush(f)</b></dt> <dd> <p>This corresponds to fflush().</p> </dd> <dt id="PerlIO_tell(f)"><a class="permalink" href="#PerlIO_tell(f)">#</a><a id="PerlIO_tell"></a><a id="PerlIO_tell-f"></a><b>PerlIO_tell(f)</b></dt> <dd> <p>This corresponds to ftell().</p> </dd> <dt id="PerlIO_seek(f,o,w)"><a class="permalink" href="#PerlIO_seek(f,o,w)">#</a><a id="PerlIO_seek"></a><a id="PerlIO_seek-f-o-w"></a><b>PerlIO_seek(f,o,w)</b></dt> <dd> <p>This corresponds to fseek().</p> </dd> <dt id="PerlIO_getpos(f,p),-PerlIO_setpos(f,p)"><a class="permalink" href="#PerlIO_getpos(f,p),-PerlIO_setpos(f,p)">#</a><a id="PerlIO_getpos"></a><a id="PerlIO_getpos-f-p-PerlIO_setpos-f-p"></a><b>PerlIO_getpos(f,p)</b>, <b>PerlIO_setpos(f,p)</b></dt> <dd> <p>These correspond to fgetpos() and fsetpos(). If platform does not have the stdio calls then they are implemented in terms of PerlIO_tell() and PerlIO_seek().</p> </dd> <dt id="PerlIO_rewind(f)"><a class="permalink" href="#PerlIO_rewind(f)">#</a><a id="PerlIO_rewind"></a><a id="PerlIO_rewind-f"></a><b>PerlIO_rewind(f)</b></dt> <dd> <p>This corresponds to rewind(). Note may be redefined in terms of PerlIO_seek() at some point.</p> </dd> <dt id="PerlIO_tmpfile()"><a class="permalink" href="#PerlIO_tmpfile()">#</a><a id="PerlIO_tmpfile"></a><b>PerlIO_tmpfile()</b></dt> <dd> <p>This corresponds to tmpfile(), i.e., returns an anonymous PerlIO which will automatically be deleted when closed.</p> </dd> </dl> <h2 id="Co-existence-with-stdio"><a class="permalink" href="#Co-existence-with-stdio">#</a><a id="Co"></a>Co-existence with stdio</h2> <p>There is outline support for co-existence of PerlIO with stdio. Obviously if PerlIO is implemented in terms of stdio there is no problem. However if perlio is implemented on top of (say) sfio then mechanisms must exist to create a FILE * which can be passed to library code which is going to use stdio calls.</p> <dl> <dt id="PerlIO_importFILE(f,flags)"><a class="permalink" href="#PerlIO_importFILE(f,flags)">#</a><a id="PerlIO_importFILE"></a><a id="PerlIO_importFILE-f-flags"></a><b>PerlIO_importFILE(f,flags)</b></dt> <dd> <p>Used to get a PerlIO * from a FILE *. May need additional arguments, interface under review.</p> </dd> <dt id="PerlIO_exportFILE(f,flags)"><a class="permalink" href="#PerlIO_exportFILE(f,flags)">#</a><a id="PerlIO_exportFILE"></a><a id="PerlIO_exportFILE-f-flags"></a><b>PerlIO_exportFILE(f,flags)</b></dt> <dd> <p>Given an PerlIO * return a 'native' FILE * suitable for passing to code expecting to be compiled and linked with ANSI C <i>stdio.h</i>.</p> <p>The fact that such a FILE * has been 'exported' is recorded, and may affect future PerlIO operations on the original PerlIO *.</p> </dd> <dt id="PerlIO_findFILE(f)"><a class="permalink" href="#PerlIO_findFILE(f)">#</a><a id="PerlIO_findFILE"></a><a id="PerlIO_findFILE-f"></a><b>PerlIO_findFILE(f)</b></dt> <dd> <p>Returns previously 'exported' FILE * (if any). Place holder until interface is fully defined.</p> </dd> <dt id="PerlIO_releaseFILE(p,f)"><a class="permalink" href="#PerlIO_releaseFILE(p,f)">#</a><a id="PerlIO_releaseFILE"></a><a id="PerlIO_releaseFILE-p-f"></a><b>PerlIO_releaseFILE(p,f)</b></dt> <dd> <p>Calling PerlIO_releaseFILE informs PerlIO that all use of FILE * is complete. It is removed from list of 'exported' FILE *s, and associated PerlIO * should revert to original behaviour.</p> </dd> <dt id="PerlIO_setlinebuf(f)"><a class="permalink" href="#PerlIO_setlinebuf(f)">#</a><a id="PerlIO_setlinebuf"></a><a id="PerlIO_setlinebuf-f"></a><b>PerlIO_setlinebuf(f)</b></dt> <dd> <p>This corresponds to setlinebuf(). Use is deprecated pending further discussion. (Perl core uses it <i>only</i> when "dumping"; it has nothing to do with $| auto-flush.)</p> </dd> </dl> <p>In addition to user API above there is an "implementation" interface which allows perl to get at internals of PerlIO. The following calls correspond to the various FILE_xxx macros determined by Configure. This section is really of interest to only those concerned with detailed perl-core behaviour or implementing a PerlIO mapping.</p> <dl> <dt id="PerlIO_has_cntptr(f)"><a class="permalink" href="#PerlIO_has_cntptr(f)">#</a><a id="PerlIO_has_cntptr"></a><a id="PerlIO_has_cntptr-f"></a><b>PerlIO_has_cntptr(f)</b></dt> <dd> <p>Implementation can return pointer to current position in the "buffer" and a count of bytes available in the buffer.</p> </dd> <dt id="PerlIO_get_ptr(f)"><a class="permalink" href="#PerlIO_get_ptr(f)">#</a><a id="PerlIO_get_ptr"></a><a id="PerlIO_get_ptr-f"></a><b>PerlIO_get_ptr(f)</b></dt> <dd> <p>Return pointer to next readable byte in buffer.</p> </dd> <dt id="PerlIO_get_cnt(f)"><a class="permalink" href="#PerlIO_get_cnt(f)">#</a><a id="PerlIO_get_cnt"></a><a id="PerlIO_get_cnt-f"></a><b>PerlIO_get_cnt(f)</b></dt> <dd> <p>Return count of readable bytes in the buffer.</p> </dd> <dt id="PerlIO_canset_cnt(f)"><a class="permalink" href="#PerlIO_canset_cnt(f)">#</a><a id="PerlIO_canset_cnt"></a><a id="PerlIO_canset_cnt-f"></a><b>PerlIO_canset_cnt(f)</b></dt> <dd> <p>Implementation can adjust its idea of number of bytes in the buffer.</p> </dd> <dt id="PerlIO_fast_gets(f)"><a class="permalink" href="#PerlIO_fast_gets(f)">#</a><a id="PerlIO_fast_gets"></a><a id="PerlIO_fast_gets-f"></a><b>PerlIO_fast_gets(f)</b></dt> <dd> <p>Implementation has all the interfaces required to allow perl's fast code to handle <FILE> mechanism.</p> <pre><code class="plaintext">PerlIO_fast_gets(f) = PerlIO_has_cntptr(f) && \ PerlIO_canset_cnt(f) && \ `Can set pointer into buffer'</code></pre> </dd> <dt id="PerlIO_set_ptrcnt(f,p,c)"><a class="permalink" href="#PerlIO_set_ptrcnt(f,p,c)">#</a><a id="PerlIO_set_ptrcnt"></a><a id="PerlIO_set_ptrcnt-f-p-c"></a><b>PerlIO_set_ptrcnt(f,p,c)</b></dt> <dd> <p>Set pointer into buffer, and a count of bytes still in the buffer. Should be used only to set pointer to within range implied by previous calls to <code>PerlIO_get_ptr</code> and <code>PerlIO_get_cnt</code>.</p> </dd> <dt id="PerlIO_set_cnt(f,c)"><a class="permalink" href="#PerlIO_set_cnt(f,c)">#</a><a id="PerlIO_set_cnt"></a><a id="PerlIO_set_cnt-f-c"></a><b>PerlIO_set_cnt(f,c)</b></dt> <dd> <p>Obscure - set count of bytes in the buffer. Deprecated. Currently used in only doio.c to force count < -1 to -1. Perhaps should be PerlIO_set_empty or similar. This call may actually do nothing if "count" is deduced from pointer and a "limit".</p> </dd> <dt id="PerlIO_has_base(f)"><a class="permalink" href="#PerlIO_has_base(f)">#</a><a id="PerlIO_has_base"></a><a id="PerlIO_has_base-f"></a><b>PerlIO_has_base(f)</b></dt> <dd> <p>Implementation has a buffer, and can return pointer to whole buffer and its size. Used by perl for <b>-T</b> / <b>-B</b> tests. Other uses would be very obscure...</p> </dd> <dt id="PerlIO_get_base(f)"><a class="permalink" href="#PerlIO_get_base(f)">#</a><a id="PerlIO_get_base"></a><a id="PerlIO_get_base-f"></a><b>PerlIO_get_base(f)</b></dt> <dd> <p>Return <i>start</i> of buffer.</p> </dd> <dt id="PerlIO_get_bufsiz(f)"><a class="permalink" href="#PerlIO_get_bufsiz(f)">#</a><a id="PerlIO_get_bufsiz"></a><a id="PerlIO_get_bufsiz-f"></a><b>PerlIO_get_bufsiz(f)</b></dt> <dd> <p>Return <i>total size</i> of buffer.</p> </dd> </dl> </div> <div id="footer"> <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p> <p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> <script src="/js/highlight.pack.js"></script> <script>hljs.highlightAll();</script> </body> </html>