Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: One Liners by blazar
in thread One Liners by lakeTrout

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-03-28 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found