|
 |
Orchid XP v8 <voi### [at] dev null> wrote:
> > If you need more complicated things like that, then often 'awk' or 'perl'
> > can be used (still usually with shorter commands and faster than writing
> > your own program would).
> I would debate that, but let's not start another argument...
Are you saying that you don't think one could write a significantly
shorter command using perl than with your favorite language? Maybe you
just don't know that perl can be used directly from the command line,
giving the "program" as an argument, and hence it can be used very much
like grep or sed. For example:
perl -pe 's|\d+|$&+1|ge' file.txt
This searches for any consecutive digits in 'file.txt', interprets them
as numbers and outputs the contents of the file but with each of these
numbers incremented by 1. (Thus if the file had a something like
"value = 123;" somewhere, the result would have "value = 124;" instead.)
I don't know Haskell too well, but I'm pretty certain it takes a bit
more code to do that (and additionally you probably can't just write the
code on the command line).
(And yes, I know that the string given to perl looks gibberish to you.
It's not gibberish when you understand what it means.)
Of course this is just a simple example. Perl can be used to make
significantly more complex substitutions (and other things) in a similar
way.
--
- Warp
Post a reply to this message
|
 |