1. Shlomi Fish
  2. perl-begin


perl-begin / src / topics / files-and-directories / index.html.wml

#include '../template.wml'
#include "xhtml/1.x/std/toc.wml"
#include "files_dirs_modules.wml"

<script type="text/javascript" src="$(ROOT)/js/jquery-ui-1.9.2.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="$(ROOT)/css/smoothness/jquery-ui-1.9.2.custom.min.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="$(ROOT)/jqui-override.css" media="screen, projection" />

<latemp_subject "Files and Directories Handling in Perl" />

Perl has strong support for handling files and directories, which are the
bread-and-butter of dealing with the disk and the filesystem. Many modules
on <a href="$(ROOT)/topics/cpan/">CPAN (= the Comprehensive Perl Archive Network)</a>
aim to facilitate the task even further.

<h2* id="toc">Table of Contents</h2*>

<toc />

<h2 id="basics">The Basics</h2>

For the basics, read about the open function (on
<pdoc d="perlopentut"></pdoc> or
on <a href="$(ROOT)/resources/">recommended books or tutorials</a>) as well as
other built-ins such as
<pdoc_f f="opendir">opendir</pdoc_f>, <pdoc_f f="readdir">readdir</pdoc_f>,
<pdoc_f f="closedir">closedir</pdoc_f>, <pdoc_f f="mkdir">mkdir</pdoc_f>. There
are also many UNIX-oriented file-system-builtins listed on <pdoc d="perlfunc"></pdoc> which may prove of utility.

<files_and_directories_modules />

<h2 id="examples">Examples</h2>

These are a set of examples for manipulating files and directories using Perl.
Each will be shown in several versions including ones using IO-All, ones using
core modules, and if relevant ones from the command line.

<define-tag perl_code endtag="required">
<pre class="perl">
    use Text::VimColor;

    my $sh_bang = qq{#!/usr/bin/perl\n\n};
    my $s = $sh_bang . <<'EOF_BLAH_BLAH_YES_THIS_IS_PERL_CODE_TO_PASS_TO_VIM';
use strict;
use warnings;

    my $tvc = Text::VimColor->new(
        string => \$s,
        filetype => 'perl',
    print $tvc->html() =~ s{(class=")syn}{$1}gr;

<script type="text/javascript">
    $(function() {

    use PerlBegin::TopicsExamples::FilesAndDirs;

    use strict;
    use warnings;