Useful Perl Modules

A lightning talk for the Perl Workshop in Israel, 2007, by Mikhael Goikhman.

See index page.

Eight Useful Modules

A quick introduction into the following useful modules:

BTW, the source of this slide is in Text::WikiText format.

File::Operations

Saving file

	save_file($filename, $content);
	save_file($filename, $content_ref);
	save_file($filename, \@lines);
	save_file($filename, $content, create_dirs => 1, is_utf8 => 0);

	append_file($filename, $content);

Loading file

	my $content = load_file($filename);
	load_file($filename, \$content);
	load_file($filename, \@lines);
	my $content = load_file($filename, is_utf8 => 1);

File::Operations (cont.)

Other file-system operations

	make_path("/tmp/my-own/dir0");
	make_dir("/tmp/my-own/dir", 0711);
	copy_file("/etc/issue", "/tmp/my-own/dir/issue");
	remove_file("/tmp/my-own/dir/issue2");
	clean_dir("/tmp/my-own/dir");  # no effect, empty already
	remove_dir("/tmp/my-own");

Saving/loading tabular fields (TAB separated lines)

	save_field_file($filename, $lines_of_fields);
	my $lines_of_fields2 = load_field_file($filename);

	save_field_file($filename, $table, create_dirs => 1, delim => ',');
	my $table2 = load_field_file($filename, delim => ',');

Text::WikiText

Simple human-readable syntax

This is a new wiki text. Write bold words, italic words, underlined words and more. Paragraphs are delimited by an empty line.

See syntax specification for the exact rules.

Tables

Tablesaresimple
123
4two columns
567

Another table:

HTTPcodes
301Moved
302Found
403Forbidden
404Not found
500Internal Error

See the source of this slide.

Text::WikiText (cont.)

Lists

There are several kinds of lists

More examples

	preformatted text
		as is
if ($condition) {
	print "This is a code.";
}

Quotations:

A language that doesn't affect the way you think about programming, is not worth knowing.

-- Alan Perlis

See the source of this slide.

Data::NeatDump

    use Data::NeatDump;

    print dump($long_struct);
    print Dump($data1, $data2, $data3);
    [
        "First element",
        {
            key1 => "Short string",
            key2 => "Another string",
        },
        [
            2.71828182845905,
            3.14159265358979,
        ],
    ]

Why not Data::Dumper?

Several reasons:

Thank you

References: