Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: One Liners

by blazar (Canon)
on Jan 11, 2005 at 11:07 UTC ( #421239=note: print w/ replies, xml ) Need Help??


in reply to One Liners

I'm new here and finally have a question that I couldn't find and answer to (a first). Can anyone point me to some resources/documentation/tutorials etc on perl one-liners?
Well, a few other monks already gave you some answers addressing exactly your question. As an example of a one-liner I routinely use I'll give:
perl -lpi.bak -e "" <file(s)>
under Windows to convert from *NIX-style \n's to Redmondish ones (yes, I know there are tons other WTDI both in Perl and with other tools - but this way I don't even have to remember which is which).

The -i.bak is there because under Windows (at least 98 or earlier, that is, and if things have not changed recently) you can't have -i without backups...

I have picked up some things here and there, but would like better explanations on what the options like -pie, pack and alike do and what they are for.
The answer to all of these question is out there, in the docs: please check
perldoc pelrun
perldoc -f pack
perldoc perlpacktut

Please note that in certain environments the kind of answer such a question would get could be at best an educated RTFM.

However I would like to point out that while indeed -pie has to do with one-liners, pack() is yet another Perl function, so you can use it in a one-liner, granted; but I don't see how it can be strictly related to your question (however I hope the tutorial above will help you).

In any case -pie is just the same as -p -i -e: -p adds a loop around your program, that is given on the cmd line itself by means of -e and finally -i does inline editing. You can check by yourself what -p adds to your code:

$ perl -MO=Deparse, -pe '' LINE: while (defined($_ = <ARGV>)) { (); } continue { print $_; } -e syntax OK


Comment on Re: One Liners
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://421239]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-11-24 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (144 votes), past polls