[Israel.pm] new module for CPAN: Getopt::Long::String

Yuval Kogman nothingmuch at woobling.org
Mon Jan 30 00:43:24 PST 2006


On Mon, Jan 30, 2006 at 10:26:34 +0200, Shlomi Fish wrote:
> On Sunday 29 January 2006 23:39, Levenglick Dov-RM07994 wrote:
> > sub GetOptions {
> > 	my @_ARGV = @ARGV;
> > 	@ARGV = split /\s+/, shift;
> > 	my $rc = &Getopt::Long::GetOptions;
> > 	@ARGV = @_ARGV;
> > 	return $rc;
> > }
> >
> 
> Do you intend that inidividual arguments may contain whitespaces? Like:
> 
> -m "Hi Dov, this is Shlomi" -t Right\ there
> 
> What about backslashes, and other stuff.
> 
> I wrote a command line arguments splitter for a subset of the Bourne Shell 
> syntax here:
> 
> http://svn.berlios.de/viewcvs/fc-solve/trunk/fc-solve/source/cl_chop.c?rev=705&view=log
> 
> It is written in C, and the code is a bit hideous. You might wish to have 
> something similar for your code.

Why bother? 

	use String::Escape qw/string2list/;

	sub GetOptions {
		local @ARGV = string2list(shift);
		goto &Getopt::Long::GetOptions;
	}

-- 
 ()  Yuval Kogman <nothingmuch at woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me dodges cabbages like macalypse log N: neeyah!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20060130/a4535f25/attachment.pgp 


More information about the Perl mailing list