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

Posted by Stefan Lasiewski on Stack Overflow See other posts from Stack Overflow or by Stefan Lasiewski
Published on 2010-05-12T20:30:21Z Indexed on 2010/05/16 0:20 UTC
Read the original article Hit count: 729

Filed under:
|

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 example, I'm using the following command (from nagios.com):

tail -f /var/log/nagios/nagios.log | perl -pe 's/(\d+)/localtime($1)/e'

I'd to replace it with something like this:

tail -f /var/log/nagios/nagios.log | ~/bin/nagiostime.pl

However, I can't figure out the best way to quickly throw this stuff into a script. Does anyone have a quick way to throw these one-liners into a Bash or Perl script?

© Stack Overflow or respective owner

Related posts about perl

Related posts about command-line