Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (Golf) Friday Golf: Print Formatted Sequence of Digits

by sauoq (Abbot)
on Aug 14, 2003 at 19:17 UTC ( [id://283972]=note: print w/replies, xml ) Need Help??


in reply to (Golf) Friday Golf: Print Formatted Sequence of Digits

perl -le 'print qq(@{["002".."020"]})'

Update:

perl -le'$,=$";print"002".."020"'

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

Replies are listed 'Best First'.
Re: Re: (Golf) Friday Golf: Print Formatted Sequence of Digits (0 :)
by BrowserUk (Patriarch) on Aug 14, 2003 at 20:33 UTC

    Look Ma! No quotes!

    perl -l40eprint,for'002'..'020'

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

      Gee... that doesn't work for me. Here's why:

      $ perl -MO=Deparse -l40eprint,for'002'..'020' BEGIN { $/ = "\n"; $\ = " "; } print($_), 'for002' .. 16; -e syntax OK

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

        Well. If you insist on using shells that muck around with the input before your programs get a chance to see it :^)

        P:\test>perl -MO=Deparse -l40eprint,for'002'..'020' BEGIN { $/ = "\n"; $\ = " "; } foreach $_ ('002' .. '020') { print $_; } -e syntax OK P:\test>perl -l40eprint,for'002'..'020' 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 01 +9 020

        Works fine for me :)


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
        If I understand your problem, I can solve it! Of course, the same can be said for you.

      That didn't work for me. All it did was print a space. (Both 5.6.0 on AIX and 5.8.0 on Solaris.)

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      Nice. 24.. you guys are getting dangerously close. ;-) No quotes, btw? Then what are those four thingies? ;^)

      Makeshifts last the longest.

Re: Re: (Golf) Friday Golf: Print Formatted Sequence of Digits
by roju (Friar) on Aug 14, 2003 at 20:00 UTC
    I was suprised no one else came up with the magic increment. I had
    perl -e 'print"$_ "for"002".."020"'
    since I didn't remember $,.

Log In?
Username:
Password:

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

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

    No recent polls found