Why bash+awk+sed+..., when you can use Perl? ;)

Post on 24-Jul-2015

1.602 views 2 download

Transcript of Why bash+awk+sed+..., when you can use Perl? ;)

Why bash+awk+sed+..., when you can use Perl? ;)

Luciano Rocha

June 6th, 2008

Introduction

1 There can be only one!

2 Why reinvent the wheel?

3 No more glue!

4 Vrooom!

There can be only one! (or, Portability)

Perl is more portable!

Different operating systems have different versions of the basic tools:

Is /bin/sh bash? dash? ...?

Does ‘xargs -r’ work?

Does ‘find’ assume ‘.’? Does it have the printf formats you need?

Does ‘sed -i‘ work?

Must options always come first?

Why reinvent the wheel? (or, Work intelligently)

Use other people’s work

Extensive documentation with great examples.

CPAN is huge!

Cookbooks!

No more glue!

Getting tired of typing long lines?

If you’re going to write a script, use a portable and powerful language.And don’t depend on external commands that may not work the samebetween platforms, breaking your scripts.

Vrooom! (or, It’s fast)

Perl is faster

Ignoring start overhead, the same algorithms will be faster in Perl than in acombination of shell, sed, awk and other things.

Don’t torture yourself

A proper programming language, with associative arrays, most of POSIXfunctions, and a extensive library.