Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

ēRe^3: Golfing on a quiet Friday afternoon...

by vladb (Vicar)
on Jul 26, 2002 at 22:04 UTC ( [id://185676]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Golfing on a quiet Friday afternoon...
in thread Golfing on a quiet Friday afternoon...

Ahh, certainly this is cheating BrowserUk {grin}.

The version of emulated DOS on your Win32 system always places new command prompt on a separate line by itself. So, even if your perl script prints just '13' without a terminating '\n', DOS would do the job for you.

However, for a Unix system I can't see how one could go shorter than just:
#12345678901234 print-s pop,$/
Which is 14 characters.

Surely, had japhy considered writing his golf for DOS, then the ',$/' part would be dropped thereby reducing the golf even further by 3 characters as you've pointed out ;-)

Update: To clarify, the word 'cheating' should be considered a sarcasm ;^). I didn't mean to sound offending. I very much respect BrowserUk's comment and have nothing against him pointing out the intimate features of perl running on various non *nix systems. I simply felt it would be worthwhile to also direct your attention to the minor difference in running the golf piece on Win32 and Unix systems.

_____________________
# Under Construction

Replies are listed 'Best First'.
Re: īŋŊRe^3: Golfing on a quiet Friday afternoon...
by BrowserUk (Patriarch) on Jul 26, 2002 at 23:20 UTC

    Cheating? Possibly, except is

    Fully utilizing implied and default behaviours....

    One possibly definition of the word perlish?

    If so, does this desirability stop at Perl's front (or back) door? :^p


    On a slightly serious note, if you run japhy's mini masterpiece on itself on a *nix box, what does it report its own length to be? 14|15|16??

    I assume this will depend on whether the editor used to create the file automatically terminates the last (only) line, and how it is terminated?

Re: ēRe^3: Golfing on a quiet Friday afternoon...
by sauoq (Abbot) on Jul 27, 2002 at 00:14 UTC
    $ echo -n 'print-s pop,$/' > golf $ perl golf golf 14

    As japhy didn't specify a newline at the end, I assume he didn't want one. :-)

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

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

    No recent polls found