Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd love to hear any questions or feedback. I've gotten quite a bit of use from this tool personally and have had a lot of fun making it.


Really looking forward to trying this out. The syntax looks very clean & clear. I hate the insanity of sed, and assuming the performance is here, I’d switch to this in a heartbeat.


In my experience, Perl outperforms sed on most equivalent commands. I should do some benchmarking and add it to the documentation.


You should really use psed then, which came with perl5 from 5.002 until v5.21.1 and is now on CPAN. This is a proper sed, implemented in perl.

https://metacpan.org/pod/release/RJBS/perl-5.21.0/x2p/s2p.PL https://metacpan.org/pod/release/LEONT/App-s2p-1.000/script/...


that would depend on a lot of factors

sed provides only BRE/ERE which has lot less features than perl, however in my experience speed is better with BRE/ERE than PCRE, except patterns with backreferences. see also [1]

a simple example:

    $ time sed 's/at/AT/g' /usr/share/dict/words > /dev/null 
    real    0m0.041s
    user    0m0.037s
    sys     0m0.004s
    $ time perl -pe 's/at/AT/g' /usr/share/dict/words > /dev/null 
    real    0m0.056s
    user    0m0.051s
    sys     0m0.004s

    $ time LC_ALL=C sed -nE '/^([a-z]..)\1$/p' /usr/share/dict/words > /dev/null 
    real    0m0.049s
    user    0m0.048s
    sys     0m0.000s
    $ time perl -ne 'print if /^([a-z]..)\1$/' /usr/share/dict/words > /dev/null 
    real    0m0.041s
    user    0m0.033s
    sys     0m0.007s


[1] https://swtch.com/~rsc/regexp/regexp1.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: