--- Michael Campbell <michael_s_campbell / yahoo.com> wrote: > (I think...)
> 
> Having a brain-fade today.  Is there a simple ruby equivalent to
> perl's qw() construct?  I want, in order to save typing, to convert a
> list of non-quoted words like so:
> 
> foo bar baz...
> 
> into an array of quoted strings: ["foo", "bar", "baz", ...]
> 
> Perl does this by:  @list = qw(foo bar baz ...);
> 
> this works... list = "foo bar baz".scan(/\w+/)
> as does: list = "foo bar baz".split(/ /)

list = %q(foo bar baz)

> but both seem wieldy and heavy-handed.
> 
> 
> #2
> 
> Is there a way to get matched data into variables without using
> matchdata, or perl ugly-variables?
> 
> Again, in perl I could do something like:
> 
> $_ = "Dec 12";
> (mon, day) = /(\w+) (\d+)/;

this = "Dec 12"
that = $1 if this =~ /(\w+) (\d+)/
other = $2 if this =~ /(\w+) (\d+)/

HTH,

-- Thomas Adam

=====
Thomas Adam

"The Linux Weekend Mechanic" -- www.linuxgazette.com

________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/