Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Can I write useful perl programs on the command line?

by faq_monk (Initiate)
on Oct 13, 1999 at 02:56 UTC ( #789=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at perldoc.perl.org.

Here is our local, out-dated (pre-5.6) version:

Yes. Read the perlrun manpage for more information. Some examples follow. (These assume standard Unix shell quoting rules.)

    # sum first and last fields
    perl -lane 'print $F[0] + $F[-1]' *

    # identify text files
    perl -le 'for(@ARGV) {print if -f && -T _}' *

    # remove (most) comments from C program
    perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c

    # make file a month younger than today, defeating reaper daemons
    perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *

    # find first unused uid
    perl -le '$i++ while getpwuid($i); print $i'

    # display reasonable manpath
    echo $PATH | perl -nl -072 -e '
        s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'

Ok, the last one was actually an obfuscated perl entry. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[oakbox]: Anyone else having difficulty looking at search.cpan.org?
[oakbox]: I keep getting a proxy error.
[marto]: try http://metacpan. org/
[marto]: I can't access search.cpan right now either. I prefer the metacpan search and general formatting anyway. Also it seems faster
[oakbox]: Yeah, the front page of cpan.org uses metacpan.org now for search results
[oakbox]: but there are a billion links 'out there' linking to search.cpan.org.
[marto]: yep :)
[Discipulus]: being her marto, can you explain what "Par for the course I'm afraid." means?
Discipulus here..
[marto]: "what is normal or expected in any given circumstances."

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-07-26 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (388 votes). Check out past polls.