From: Brian Candler Date: 2003-03-28T17:50:01+09:00 Subject: Re: Newbie question:Does Ruby have the structure of hash's array like Perl does? On Fri, Mar 28, 2003 at 05:15:49PM +0900, Daniel Carrera wrote: > > Perl's $" just like OFS in awk which is the output field separator,i.e. > > that is printed between fields. > > I'm not sure I understand. Can you give me an example of Perl code that > uses $"? > > Regardless, its almost certain that Ruby's equivalent is $". > AFAIK Ruby has carbon-copied nearly all of Perl's special variables. > > Please do show me what $" does. I'd like to know. If you interpolate an array into a double-quoted string, it's the separator used to join them. In Ruby it would be the default separator for join, which is $, $ perl -e '@a=("jim","bob"); $"="-"; print "@a\n"' jim-bob $ ruby -e 'a=["jim","bob"]; puts a.join("-")' jim-bob $ ruby -e 'a=["jim","bob"]; $,="-"; puts a.join' jim-bob Perl has $, too, but that's used as the output field separator when giving multiple variables to 'print'. There's no distinction in Ruby, since "print a,b,c" is pretty much the same as "print [a,b,c]" Regards, Brian.