How can I convert Perl one-liners into complete scripts?

前端 未结 6 811
旧巷少年郎
旧巷少年郎 2020-12-24 03:06

I find a lot of Perl one-liners online. Sometimes I want to convert these one-liners into a script, because otherwise I\'ll forget the syntax of the one-liner.

For e

6条回答
  •  醉酒成梦
    2020-12-24 03:53

    #!/usr/bin/env perl
    
    while(<>) {
        s/(\d+)/localtime($1)/e;
        print;
    }
    

    The while loop and the print is what -p does automatically for you.

提交回复
热议问题