|
![](/i/fill.gif) |
>> 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?
...alternatively, let's start another argument... *sigh*
>
> 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
It does. (If only because of the difficulty of number parsing.) But a
more relevant question would be... why would you want to do this? Is
Haskell (or anything else) easier or harder for textual manipulations
that actually do something useful?
> (and additionally you probably can't just write the
> code on the command line).
Actually you can. (But obviously you *only* want to do this if the code
is short...)
> 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.
Again, I guess it depends on what you want to do. For example, some guy
invented "markdown", and wrote a Perl script to turn it into HTML or
whatever. And then a bunch of Haskell guys wrote their own
implementation, which was faster, had fewer bugs (i.e., it matched the
documentation more closely), and had more features.
Then again, not every task is as complicated as markup conversion...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |