tag:blogger.com,1999:blog-753668960778118906.post3732154188553592643..comments2021-03-22T10:54:50.159+01:00Comments on How Can I Explain This?: Frequently freaky freakin' one-linersbakkushanhttp://www.blogger.com/profile/05417272581094785872noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-753668960778118906.post-47943702136485873342009-06-24T09:58:02.060+02:002009-06-24T09:58:02.060+02:00While the blog entry was supposed to be a bit of a...While the blog entry was supposed to be a bit of a whine than a request for help:<br /><br />Thanks, that seems convenient for at least some of the cases.bakkushanhttps://www.blogger.com/profile/05417272581094785872noreply@blogger.comtag:blogger.com,1999:blog-753668960778118906.post-33240899099824258892009-06-15T21:28:44.752+02:002009-06-15T21:28:44.752+02:00Hey, not to be bragging (or doing shameless propag...Hey, not to be bragging (or doing shameless propaganda), but I think I wrote a module for you! :P<br /><br />It's called <a href="http://search.cpan.org/perldoc?App::Rad" rel="nofollow">App::Rad</a>, and here's how to use it for your purposes:<br /><br />Create a file called "myapp.pl" or whatever, with this in it:<br /><br />----------8<----------<br />#!/usr/bin/perl<br />use App::Rad qw(include);<br />App::Rad->run();<br />---------->8----------<br /><br />And put it in your path. Then, next time you make a nice one-liner and want to keep it, change "perl" to "myapp.pl include NAME", so this:<br /><br />> perl -i -pe "s/aaa/bbb" file.txt<br /><br />becomes this:<br /><br />> myapp.pl include replace -i -pe "s/aaa/bbb"<br /><br />it will create a "replace" command for your app so next time you want to use it you can just do:<br /><br />> myapp.pl replace file.txt<br /><br />you can see all available commands created by you just typing "myapp.pl" without arguments.<br /><br />App::Rad has a lot of functionality built in to create command-line apps, but for your needs maybe the <a href="http://search.cpan.org/perldoc?App::Rad#include_%5Bcommand_name%5D_-perl_params_'your_subroutine_code'" rel="nofollow">"include" command</a> will suffice. It will let you store your one-liners in a reusable way - maybe even allowing you to expand and refactor them as you see fit.<br /><br />If you can, please give it a try and let me know what you think. Thanks!garuhttps://www.blogger.com/profile/00553247579311713092noreply@blogger.com