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

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.

  • Comment on Re: Re: Re: Re: (Golf) Friday Golf: Print Formatted Sequence of Digits (0 :)
  • Download Code

Replies are listed 'Best First'.
Re^5: (Golf) Friday Golf: Print Formatted Sequence of Digits (0 :)
by Aristotle (Chancellor) on Aug 14, 2003 at 21:39 UTC

    The shell is not mucking around with the input one bit. It interprets single quotes for itself, though, so Perl gets to see a literal 002..020. It works if you backslash the single quotes.

    I far prefer a slight inconvenience in cases like this over having to work around a braindead (lack of) quoting mechanisms for the general case. Although CMD.EXE has borrowed enough bashishms that's it's barely bearable nowadays..

    Makeshifts last the longest.

      It interprets single quotes for itself,...

      Exactly. It's mucking about with stuff that's intended for the program :)

      </very toungue in cheek>


      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.