Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: perl one-liner doesn't autochomp input

by jbullock35 (Hermit)
on Sep 07, 2004 at 13:02 UTC ( #389017=note: print w/ replies, xml ) Need Help??


in reply to Re: perl one-liner doesn't autochomp input
in thread perl one-liner doesn't autochomp input

$ ls | perl -l72pe1

This works and seems equivalent to

$ ls | perl -l72pe "{}"

But I don't understand the role of "1" (or digits in general) at the end of the command line, and I can't find any explanation in perlrun. I thought that they might affect the way that arguments are processed, but that doesn't seem right. Can someone clarify?

Thanks,
--John


Comment on Re^2: perl one-liner doesn't autochomp input
Select or Download Code
Re^3: perl one-liner doesn't autochomp input
by Anonymous Monk on Sep 07, 2004 at 13:05 UTC
Re^3: perl one-liner doesn't autochomp input
by Aristotle (Chancellor) on Sep 07, 2004 at 18:16 UTC

    The 1 is there because you have to supply some Perl code to -e, but in this case you don't care to do anything, you just want the side effects of the other switches. Using a 1 by itself as your "script" is just like having 1; on a line by itself in a script — it does nothing.

    This can be used for such funny command lines as

    perl -please textfile # print the contents of the textfile perl -deal # fire up the debugger for interactive fiddling

    These are equivalent to

    perl -p -l -e '"ase"' textfile perl -d -e '"al"'

    where you simply have a string on a line by itself as the only statement in your "code", resulting in a no-op.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-04 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls