From: serialhex Date: 2011-06-29T06:37:51+09:00 Subject: Re: here docs: WTF am i doing wrong??? --0016e645ab029fbc3604a6cc7a3f Content-Type: text/plain; charset=ISO-8859-1 thanks J-H!! that works BEAUTIFULLY!!! (though why that works and the other doesn't is a mystery to me, seems like it violates the principle of least surprise) hex On Tue, Jun 28, 2011 at 5:27 PM, J-H Johansen wrote: > On Tue, Jun 28, 2011 at 11:17 PM, serialhex wrote: > > > ok, so i'm trying to create a here doc for a little program i'm writing > and > > it dosn't seem to want to work right! > > > > this code works: > > ### > > pry(main)> print < > pry(main)* 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 > > pry(main)* 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 > > pry(main)* NUMS > > 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 > > 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 > > => nil > > ### > > > > but this: > > ### > > pry(main)> str = '' > > => "" > > pry(main)> str < > pry(main)* 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 > > pry(main)* 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 > > pry(main)* NUMS > > ### > > > > gives me: > > ### > > SyntaxError: (pry):43: Invalid octal digit > > 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 > > ^ > > (pry):43: syntax error, unexpected tINTEGER, expecting $end > > 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 > > ^ > > from > > > > > /home/serialhex/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:226:in > > `eval' > > ### > > > > so why can i 'print' a here doc, but not set it to a variable??? or am i > > doing something stupid wrong that i dont know what i'm doing with the > > stupid > > and the wrongness?? (sorry, i think i need to catch up on some sleep > too) > > > > any help is appreciated > > hex > > > > > Try this: > > irb(main):001:0> st = "" > => "" > irb(main):002:0> st << < irb(main):003:0" 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 > 08 > irb(main):004:0" NUMS > => "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\n" > irb(main):005:0> > > > > > > > > -- > > my blog is cooler than yours: serialhex.github.com > > > > > > Other than the fact Linux has a cool name, could someone explain why > I > > > > should use Linux over BSD? > > > > > > No. That's it. The cool name, that is. We worked very hard on > > > creating a name that would appeal to the majority of people, and it > > > certainly paid off: thousands of people are using linux just to be able > > > to say "OS/2? Hah. I've got Linux. What a cool name". 386BSD made > the > > > mistake of putting a lot of numbers and weird abbreviations into the > > > name, and is scaring away a lot of people just because it sounds too > > > technical. > > -- Linus Torvalds' follow-up to a question about Linux > > > > > > -- > Jens-Harald Johansen > -- > There are 10 kinds of people in the world: Those who understand binary and > those who don't... > -- my blog is cooler than yours: serialhex.github.com > > Other than the fact Linux has a cool name, could someone explain why I > > should use Linux over BSD? > > No. That's it. The cool name, that is. We worked very hard on > creating a name that would appeal to the majority of people, and it > certainly paid off: thousands of people are using linux just to be able > to say "OS/2? Hah. I've got Linux. What a cool name". 386BSD made the > mistake of putting a lot of numbers and weird abbreviations into the > name, and is scaring away a lot of people just because it sounds too > technical. -- Linus Torvalds' follow-up to a question about Linux --0016e645ab029fbc3604a6cc7a3f--