Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Resource for command line "one-liner" interpretation

by Util (Priest)
on May 15, 2003 at 21:36 UTC ( #258531=note: print w/ replies, xml ) Need Help??


in reply to Resource for command line "one-liner" interpretation

B::Deparse can translate a one-liner into a (almost) regular program. To use it, add -MO=Deparse to the beginning of perl's command line.

Using the Perl section of graff's example:

perl -MO=Deparse -ne 'chomp;$s+=$_ if($_>10240);END{print "$s\n"}'
This gives us:
LINE: while (defined($_ = <ARGV>)) { chomp $_; $s += $_ if $_ > 10240; sub END { print "$s\n"; } ; } -e syntax OK
which we can tighten up to be:
while (<>) { chomp; $s += $_ if $_ > 10240; } print "$s\n";


Comment on Re: Resource for command line "one-liner" interpretation
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-07-06 01:47 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 (68 votes), past polls