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

Levenglick Dov-RM07994 Dov at freescale.com
Mon Jan 30 01:21:24 PST 2006


How do we feel about this version (and thanks to Yuval on this most useful module)? It seems to address the main problem of multi-worded strings in $string.

package Getopt::Long::String;

use 5.004;
use Exporter;
use Getopt::Long;
use String::Escape qw( string2list);
use strict;

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

1;
 
Best Regards,
Dov Levenglick
DSP SoC System and Applications Engineer,
Network and Computing Systems Group
Freescale Semiconductor Israel
Tel. +972-9-952-2804
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
 

-----Original Message-----
From: Yuval Kogman [mailto:nothingmuch at woobling.org] 
Sent: Monday, January 30, 2006 10:43 AM
To: Perl in Israel
Cc: Levenglick Dov-RM07994
Subject: Re: [Israel.pm] new module for CPAN: Getopt::Long::String

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!




More information about the Perl mailing list