开发者

What can I do using awk that I cannot do in Perl?

I had read somewhere about one specific feature that is present in awk but not in Perl. I have failed in locating it again.

I would appreciate it if anyone here can point it out.

This might be a useless trivia, but I am still curious开发者_C百科 to know.


From perldoc perlvar:

Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-)


The awk to perl translator man page digs up one thing that Perl can't do:

  • Perl does not attempt to emulate the behavior of awk in which nonexistent array elements spring into existence simply by being referenced. (lvalue autovivification)

But in general, Perl is turing complete, it can do everything awk can do. The fact that an awk to perl translator exists should be proof enough :)


perltrap - Awk Traps lists several differences between awk and perl.

See also: a2p - Awk to Perl translator


Regular expression subroutines like

/regex/ {
         awk code here
}

for pattern matching is a feature I miss from awk.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜