What tool to use?

Rob 'Feztaa' Park feztaa at shaw.ca
Sat Aug 10 18:49:05 PDT 2002

Alas! Björn Lindberg spake thus:
> > Thanks Rob, this works great.

No problem.

> Correct. You can write both dc and sokoban in sed (it has been done),
> together with awk and shell scripting there simply is no need to ever
> touch perl. :-)

Well, aside from the fact that perl is a million times faster than bash,

> > out I needed sed, but I couldn't find in documentation on sed or regular
> > expressions on my system (the man pages and info weren't enough). I've
> > got
> > to search on google for a tutorial about regular expressions!

I didn't read the links, but if they're no good, definitely try google.
regular expressions are a total godsend whenever they're used. Consider

You have the string 'The cat sat on the mat'. You want to change 'cat'
to 'dog'. You could do it without regular expressions (in perl):

$string = 'The cat sat on the mat';
$start = index($string, 'cat', 0);
$end = index($string, ' ', $start)-$start;
substr($string, $start, $end) = 'dog';

Or with regular expressions:

$string = 'The cat sat on the mat';
$string =~ s/cat/dog/;

Of course, they're way more complicated and useful than that, but it's a
start ;)

Rob 'Feztaa' Park
<ultima> netgod: My calculator has more registers than the x86, and
         -thats- sad
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message

More information about the blfs-support mailing list