Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

(jj808) Re: (zdog) Re: One-Line Web Counter

by jj808 (Hermit)
on Sep 09, 2001 at 16:36 UTC ( [id://111276]=note: print w/replies, xml ) Need Help??


in reply to (zdog) Re: One-Line Web Counter
in thread One-Line Web Counter

More golf...

Do echo "0" >c first.

perl -MCGI -i -e 'while(<>){s!(\d+)!$t=$1+1!e;print}print CGI->new->h +eader,$t' c

JJ

Update: Removed useless semicolon.

Update 2: Even smaller now!

Replies are listed 'Best First'.
Re (tilly) 1: (jj808) Re: (zdog) Re: One-Line Web Counter
by tilly (Archbishop) on Sep 09, 2001 at 21:21 UTC
    Well leaving aside locking issues, and the point that the number 2 by itself is not exactly valid html, here is the above made even shorter.
    perl -MCGI -pi -e 'END{print&CGI::header,$t}s/\d+/$t=$&+1/e' c
    UPDATE
    And, of course, there is always a shorter way:
    perl -MCGI -pi -e'END{print&CGI::header,$t}$t=++$_' c

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-19 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found