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

6
Why bash+awk+sed+..., when you can use Perl? ;) Luciano Rocha June 6th, 2008

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

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

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

Luciano Rocha

June 6th, 2008

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

Introduction

1 There can be only one!

2 Why reinvent the wheel?

3 No more glue!

4 Vrooom!

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

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?

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

Why reinvent the wheel? (or, Work intelligently)

Use other people’s work

Extensive documentation with great examples.

CPAN is huge!

Cookbooks!

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

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.

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

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.