From: GGarramuno@... (GGarramuno) Date: 2004-01-10T19:01:41+09:00 Subject: Re: ANN: First release of Perl's Getopt::Declare for ruby nobu.nokada@softhome.net wrote in message news:<200401100221.i0A2LCr9008491@sharui.nakada.kanuma.tochigi.jp>... > Hi, > > At Fri, 9 Jan 2004 16:11:41 +0900, > GGarramuno wrote: > > >One suggestion: make it possible to apply to an arbitrary array, rather > > >than just ARGV (or is this already possible?). > > > > Yes, it's possible, but you have to convert it to a space separated String > > first (just use join ' '). > > What about strings contain spaces? > I'd say pass them in quotes and then remove the quotes, but I know that sucks. I realize now that real issue is that ARGV in ruby is, unfortunately, a read only variable and that's why the issue does not come up in perl. Hmmm... I'll see how the interface can be changed to accomodate this better perhaps. The code to add is simple, but have to figure out what's the nicest interface to it. > And, you use this construnction several times, but I don't > think you'd expect behavior as it works. > > def foo(*args) > if defined?(args[0]) > # ... > > Since args is defined here, so args[0] also is defined always. > Ruby's `defined?' operator differs from Perl's `defined' > function. > Yes, I should know better. This should only have effected the nocase label adversely. The other places where it is used work regardless of the if (there were mainly perl speed optimizations which I don't know if they are still such in ruby). I'll put up a new version once I think of a new interface to pass arbitrary arrays. I'll send an email when done. > BTW, I found a sample doesn't work expectedly. > > $ ruby ../samples/cmdline_pvtype.rb -blood AB Rh+ > -blood => { '' => "", '' => "A" } yes, it seems broken in the original perl demo code (actually, the original perl code does not even compile). The blood type is defined in the wrong order. It should be AB|[OAB] instead of [OAB]|AB else the first condition takes precedence in the regex, as it should. Or are there other blood types? Medicine ain't my strong point, I admit.