Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://421239]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-04-26 07:01 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (469 votes). Check out past polls.