[30191] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1434 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 9 11:09:44 2008

Date: Wed, 9 Apr 2008 08:09:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Apr 2008     Volume: 11 Number: 1434

Today's topics:
    Re: Perl Regex substitution: replace nth occurrance <yogeshkagrawal@gmail.com>
    Re: perl should be improved and perl6 <RedGrittyBrick@SpamWeary.foo>
        problem using system() <mikaelpetterson@hotmail.com>
    Re: problem using system() <1usa@llenroc.ude.invalid>
    Re: problem using system() <joost@zeekat.nl>
    Re: problem using system() <jjcassidy@gmail.com>
    Re: problem using system() <mikaelpetterson@hotmail.com>
    Re: problem using system() <c7eqjyg02@sneakemail.com>
    Re: problem using system() <1usa@llenroc.ude.invalid>
        SOAP <kevino_2@yahoo.com>
    Re: SOAP <name@yahoo.com>
    Re: SOAP <kevino_2@yahoo.com>
    Re: SOAP <simon.chao@fmr.com>
    Re: somewhat unusual way to define a sub <ro.naldfi.scher@gmail.com>
        Trouble with @ARGV <ff0000.it@gmail.com>
    Re: Trouble with @ARGV <peter@makholm.net>
    Re: Trouble with @ARGV <ff0000.it@gmail.com>
    Re: Trouble with @ARGV <name@yahoo.com>
    Re: Trouble with @ARGV <ff0000.it@gmail.com>
    Re: Trouble with @ARGV <ff0000.it@gmail.com>
    Re: Trouble with @ARGV <ff0000.it@gmail.com>
    Re: Trouble with @ARGV <ff0000.it@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 9 Apr 2008 01:12:10 -0700 (PDT)
From: Yogi <yogeshkagrawal@gmail.com>
Subject: Re: Perl Regex substitution: replace nth occurrance
Message-Id: <0c33f619-63d4-4edc-bd4e-6a1fb07cc8f6@m3g2000hsc.googlegroups.com>

On Apr 9, 12:05 pm, Frank Seitz <devnull4...@web.de> wrote:
> Yogi wrote:
> > I have a variable say:
> > $x =3D "this is test program with test inputs";
>
> > My requirement is to replace nth occurrance of "test" with something
> > else.  how to achieve the same using perl regex. if i do something
> > like:
> > $x =3D~ s/test/java/g;
>
> > This is going to replace all occurrance of test with "java" but my
> > requirement is to replace say 2nd occurrance only.  Any help?
>
> perldoc -q nth
>
> Frank
> --
> Dipl.-Inform. Frank Seitz;http://www.fseitz.de/
> Anwendungen f=FCr Ihr Internet und Intranet
> Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Thanks Frank for your help. :)
Regards,
-Yogi


------------------------------

Date: Wed, 09 Apr 2008 09:37:58 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: perl should be improved and perl6
Message-Id: <47fc8069$0$26082$db0fefd9@news.zen.co.uk>

Gordon Etly wrote:
> It appears to me that most of you who are so bent against the usage of 
> "PERL" are missing or just plain ignoring 'perldoc perl' 

perldoc perl
NAME
     perl - Practical Extraction and Report Language

SYNOPSIS
     perl ...

     If you're new to Perl, ...


I note that perldoc perl does NOT say
NAME
     PERL - Practical Extraction and Report Language

SYNOPSIS
     PERL ...

     If you're new to PERL, ...


QED

-- 
RGB


------------------------------

Date: Wed, 9 Apr 2008 05:42:24 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: problem using system()
Message-Id: <6f8e80dd-1a07-4719-a634-18f2a21dce0f@s37g2000prg.googlegroups.com>

Hi,

I have the following string:

my $command = "$User_Preferences{"asadminexecutable"} deploy  --user=
$User_Preferences{"user"} --passwordfile=
$User_Preferences{"passwordfile"} --host=$User_Preferences{"host"} --
port=$User_Preferences{"port"} $User_Preferences{"pathdeployunit"}";
system($command);

Global symbol "$command" requires explicit package name at
remote_deploy.pl line 55.
syntax error at remote_deploy.pl line 55, at EOF
Missing right curly or square bracket at remote_deploy.pl line 55,
within string
Execution of remote_deploy.pl aborted due to compilation errors.

Any ideas what I need to do to make it possible to execute the
command?

cheers,

//mike


------------------------------

Date: Wed, 09 Apr 2008 13:18:12 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: problem using system()
Message-Id: <Xns9A7B5EA1111F2asu1cornelledu@127.0.0.1>

mike <mikaelpetterson@hotmail.com> wrote in
news:6f8e80dd-1a07-4719-a634-
18f2a21dce0f@s37g2000prg.googlegroups.co
m: 

> I have the following string:
> 
> my $command = "$User_Preferences{"asadminexecutable"} deploy 
> --user= $User_Preferences{"user"} --passwordfile=
> $User_Preferences{"passwordfile"} --host=$User_Preferences{"host"}
> -- port=$User_Preferences{"port"}
> $User_Preferences{"pathdeployunit"}"; system($command);

This is a little silly. You do realize that you do not have string,
right? You have 

"$User_Preferences{"

followed by the bareword

asadminexecutable

followed by

"} deploy  -- ..."

etc.

> Any ideas what I need to do to make it possible to execute the
> command?

I would recommend using a LIST argument with system in this case
(see perldoc -f system) unless you need some features of the shell: 

system $User_Preferences{asadminexecutable}, 
       'deploy',
    	"--user=$User_Preferences{user}",
    	"--passwordfile=$User_Preferences{passwordfile}",
       "--host=$User_Preferences{host}",
       "--port=$User_Preferences{port}",
       "$User_Preferences{pathdeployunit}";

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 09 Apr 2008 15:21:07 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: problem using system()
Message-Id: <87d4oz6u64.fsf@zeekat.nl>

mike <mikaelpetterson@hotmail.com> writes:

> Hi,
>
> I have the following string:
>
> my $command = "$User_Preferences{"asadminexecutable"} deploy  --user=
                ^^                 ^^                ^^

> $User_Preferences{"user"} --passwordfile=
                    ^^   ^^
> $User_Preferences{"passwordfile"} --host=$User_Preferences{"host"} --
                    ^^           ^^                          ^^   ^^
> port=$User_Preferences{"port"} $User_Preferences{"pathdeployunit"}";
                         ^^   ^^                   ^^             ^^^^

get rid of all the double quotes in the $hash{"lookup"} constructs. you
don't need them and they break the double quoted string they're
interpolated in.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Wed, 9 Apr 2008 06:48:29 -0700 (PDT)
From: A Dude <jjcassidy@gmail.com>
Subject: Re: problem using system()
Message-Id: <b8f2a040-f7b7-4ce5-a8cb-4f2050a5c3b2@e67g2000hsa.googlegroups.com>

On Apr 9, 8:42=A0am, mike <mikaelpetter...@hotmail.com> wrote:
> Hi,
>
> I have the following string:
>
> my $command =3D "$User_Preferences{"asadminexecutable"} deploy =A0--user=
=3D
> $User_Preferences{"user"} --passwordfile=3D
> $User_Preferences{"passwordfile"} --host=3D$User_Preferences{"host"} --
> port=3D$User_Preferences{"port"} $User_Preferences{"pathdeployunit"}";
> system($command);
>
> Global symbol "$command" requires explicit package name at
> remote_deploy.pl line 55.
> syntax error at remote_deploy.pl line 55, at EOF
> Missing right curly or square bracket at remote_deploy.pl line 55,
> within string
> Execution of remote_deploy.pl aborted due to compilation errors.
>
> Any ideas what I need to do to make it possible to execute the
> command?
>
> cheers,
>
> //mike

Actually, what you have there is a _quoting_ problem.

First of all there is no reason to delimit hash keys with the double
quotes. But if you're going to do that, you shouldn't surround the
whole string literal with double quotes. Use single quotes
( $User_Preferences{'user'} -- if any -- $User_Preferences{user} --
works just fine. ) or surround the thing with the qq operator, to
allow for the embedded double quotes.

For more on qq: perldoc perlop


------------------------------

Date: Wed, 9 Apr 2008 06:57:43 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Re: problem using system()
Message-Id: <ec4401c0-d287-4a12-9a29-8d67509b7d61@q1g2000prf.googlegroups.com>

Hi,

I changed it to ( taking all pointers into account):


my @args = ($User_Preferences{asadminexecutable}, 'deploy', "--user=
$User_Preferences{user}","--passwordfile=
$User_Preferences{passwordfile}","--host=$User_Preferences{host}","--
port=$User_Preferences{port}","$User_Preferences{pathdeployunit}");

system(@args) == 0 or die "system @args failed: $?"
if ($? == -1) {
    print "failed to execute: $!\n";
}
elsif ($? & 127) {
    printf "child died with signal %d, %s coredump\n",
        ($? & 127),  ($? & 128) ? 'with' : 'without';
}
else {
    printf "child exited with value %d\n", $? >> 8;
}

I get the following error:

Possible unintended interpolation of @args in string at
remote_deploy.pl line 63.
syntax error at remote_deploy.pl line 63, near "system"
Global symbol "@args" requires explicit package name at
remote_deploy.pl line 63.
Global symbol "@args" requires explicit package name at
remote_deploy.pl line 63.
Execution of remote_deploy.pl aborted due to compilation errors.

Does not really help me as a newbie :-)
Any ideas?

cheers,

//mike


------------------------------

Date: Wed, 9 Apr 2008 07:21:04 -0700 (PDT)
From: Japhio <c7eqjyg02@sneakemail.com>
Subject: Re: problem using system()
Message-Id: <8fb9642f-54f4-4d58-90cb-71ee6245f9d2@t12g2000prg.googlegroups.com>

On Apr 9, 3:57 pm, mike <mikaelpetter...@hotmail.com> wrote:
> Hi,
>
> I changed it to ( taking all pointers into account):
>
> my @args = ($User_Preferences{asadminexecutable}, 'deploy', "--user=
> $User_Preferences{user}","--passwordfile=
> $User_Preferences{passwordfile}","--host=$User_Preferences{host}","--
> port=$User_Preferences{port}","$User_Preferences{pathdeployunit}");
>
> system(@args) == 0 or die "system @args failed: $?"

[cut]

> Possible unintended interpolation of @args in string at
> remote_deploy.pl line 63.
> syntax error at remote_deploy.pl line 63, near "system"

^^^ Here is the nasty bit!

> Global symbol "@args" requires explicit package name at
> remote_deploy.pl line 63.
> Global symbol "@args" requires explicit package name at
> remote_deploy.pl line 63.
> Execution of remote_deploy.pl aborted due to compilation errors.
>

There is a semicolon ';' missing after the line with system().

By the way, from the error message 'Global symbol "@args" requires
explicit package name' I infer that you use the strict pragma, which
is a good thing. Now learn to interpret the error messages ;-)

> Does not really help me as a newbie :-)
> Any ideas?

Keep on trying!


------------------------------

Date: Wed, 09 Apr 2008 14:25:06 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: problem using system()
Message-Id: <Xns9A7B69F8F241Dasu1cornelledu@127.0.0.1>

mike <mikaelpetterson@hotmail.com> wrote in news:ec4401c0-d287-4a12-
9a29-8d67509b7d61@q1g2000prf.googlegroups.com:

> I changed it to ( taking all pointers into account):
> 
 ...
 
> system(@args) == 0 or die "system @args failed: $?"

There is a semi-colon missing at the end of that line.

> syntax error at remote_deploy.pl line 63, near "system"

 ...

> Does not really help me as a newbie :-)

As a newbie, you would be better helped by reading your code more 
carefully rather than asking us to figure out every syntax error.

As a newbie, you might want to learn more before writing deployment 
scripts if you don't want to ruin your customers.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 9 Apr 2008 06:29:10 -0700 (PDT)
From: KevinO <kevino_2@yahoo.com>
Subject: SOAP
Message-Id: <7b6100b4-d9ee-47dd-acce-6dbd32bafb34@x41g2000hsb.googlegroups.com>

Hi

I "inherited" a program which contains this line:
$a = $soap->call( $retrieveXmlList => @params )->result ;

I added:
print "$a\n" ;

Which produced:
HASH(0x50c5d4)

How do I proceed from here to see and parse the XML tree/data?

Thanks
KO


------------------------------

Date: Wed, 09 Apr 2008 15:40:20 +0200
From: Matija Papec <name@yahoo.com>
Subject: Re: SOAP
Message-Id: <ftih08$krr$1@ss408.t-com.hr>

KevinO wrote:
> Hi
> 
> I "inherited" a program which contains this line:
> $a = $soap->call( $retrieveXmlList => @params )->result ;
> 
> I added:
> print "$a\n" ;
> 
> Which produced:
> HASH(0x50c5d4)
> 
> How do I proceed from here to see and parse the XML tree/data?

Most probably you don't need to parse anything, as $a already contain 
final result from soap call.

use Data::Dumper;
print Dumper $a


------------------------------

Date: Wed, 9 Apr 2008 08:03:02 -0700 (PDT)
From: KevinO <kevino_2@yahoo.com>
Subject: Re: SOAP
Message-Id: <7ac0e509-0982-4d65-8afc-0e5cb3a34007@8g2000hsu.googlegroups.com>

On Apr 9, 9:40 am, Matija Papec <n...@yahoo.com> wrote:
> KevinO wrote:
> > Hi
>
> > I "inherited" a program which contains this line:
> > $a = $soap->call( $retrieveXmlList => @params )->result ;
>
> > I added:
> > print "$a\n" ;
>
> > Which produced:
> > HASH(0x50c5d4)
>
> > How do I proceed from here to see and parse the XML tree/data?
>
> Most probably you don't need to parse anything, as $a already contain
> final result from soap call.
>
> use Data::Dumper;
> print Dumper $a

Matija

Thanks for the quick response.
However, it seems that the Dumper returns only the last item in the
list.
It is very likely my ignorance in the subject.
So, if I may push it a bit...
1. How do I get everything from Dumper?
2. How would I use an XML parser here?

Many Thanks
KO


------------------------------

Date: Wed, 9 Apr 2008 08:07:35 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: SOAP
Message-Id: <f0f28bff-3f53-4d6f-bed7-25333e76c149@p25g2000hsf.googlegroups.com>

On Apr 9, 11:03=A0am, KevinO <kevin...@yahoo.com> wrote:
> On Apr 9, 9:40 am, Matija Papec <n...@yahoo.com> wrote:
>
>
>
> > KevinO wrote:
> > > Hi
>
> > > I "inherited" a program which contains this line:
> > > $a =3D $soap->call( $retrieveXmlList =3D> @params )->result ;
>
> > > I added:
> > > print "$a\n" ;
>
> > > Which produced:
> > > HASH(0x50c5d4)
>
> > > How do I proceed from here to see and parse the XML tree/data?
>
> > Most probably you don't need to parse anything, as $a already contain
> > final result from soap call.
>
> > use Data::Dumper;
> > print Dumper $a
>
> Matija
>
> Thanks for the quick response.
> However, it seems that the Dumper returns only the last item in the
> list.

Why do you jump to this conclusion rather than guess that the thing
that Dumper is trying to dump only has the last item?



------------------------------

Date: Wed, 9 Apr 2008 00:20:34 -0700 (PDT)
From: Ronny <ro.naldfi.scher@gmail.com>
Subject: Re: somewhat unusual way to define a sub
Message-Id: <50776f70-6c99-49f9-8ebe-9bb43e7e001b@e67g2000hsa.googlegroups.com>

On Apr 8, 7:21 pm, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "R" == Ronny  <ro.naldfi.sc...@gmail.com> writes:
>   R> On Apr 8, 3:07 pm, Peter Scott <Pe...@PSDT.com> wrote:
>   >> use Log::Log4Perl;
>   >> BEGIN {
>   >> for my $method ( keys %Log::Log4perl::Level::PRIORITY ) {
>   >> no strict 'refs';
>   >> *$method = sub {
>   >> my $self = shift;
>   >> my $logger = Log::Log4Perl->get_logger( ref $self );
>   >> $logger->$method( @_ );
>   >> }
>   >> };
>   >>
>   >> }
>
>   R> Well, your case *does* make sense, because $method is a different
>   R> string on every execution. My original example, however, was that
>   R> the method name was "constant" (i.e. set to the same string on every
>   R> execution), so I agree with Uri that this could have done more
>   R> naturally
>   R> in the conventional way of defineing a sub.
>
> note that these aren't strings being compiled but anon subs.

I meant: The variable $method holds a string (the name of
a priority level - for example "WARNING"), and the assignment
  *$method = sub { ... }
sets the sub slot of the symbol table entry "WARNING" to the anonymous
sub, which effectively results in a sub &WARNING to be created.

Am I wrong here?

Ronald


------------------------------

Date: Wed, 9 Apr 2008 02:17:28 -0700 (PDT)
From: ff0000 <ff0000.it@gmail.com>
Subject: Trouble with @ARGV
Message-Id: <1aa663cd-f2b1-43ef-ad15-6ff9418c90e7@a1g2000hsb.googlegroups.com>

Hi,

I'm in trouble and doubt (is it a Perl or shell (Bash) fault? :-)
while understanding the
@ARGV behaviour... Here's a simple (newbie) script:

--
#!/usr/bin/perl

print "ARGV: `" . "@ARGV" . "`\n";

for my $i (0..$#ARGV) {
        print "Argument[${i}]: `" . $ARGV[$i] . "`\n";

}

1;
--

First case:

ff0000@tsi00588pc:tmp$ ./test.pl "a b c"
ARGV: `a b c`
Argument[0]: `a b c`

The "a b c" quoting has been eating up; ok let's protect it:

ff0000@tsi00588pc:tmp$ ./test.pl \"a b c\"
ARGV: `"a b c"`
Argument[0]: `"a`
Argument[1]: `b`
Argument[2]: `c"`

Ouch! The protection has splitted the string... :-/...
Is there a way (without using extra modules) to preserve quoting
through
@ARGV?

Thanks a lot.
ff0000


------------------------------

Date: Wed, 09 Apr 2008 09:24:46 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: Trouble with @ARGV
Message-Id: <87k5j7nzxd.fsf@hacking.dk>

ff0000 <ff0000.it@gmail.com> writes:

> I'm in trouble and doubt (is it a Perl or shell (Bash) fault? :-)

It is you shell that parses the command line and places it it @ARGV,
so you question is a bash question and not really a perl question.

This would work:

  ff0000@tsi00588pc:tmp$ ./test.pl '"a b c"'

//Makholm

note) 
  well, the shell places the parsed arguments in the C equivalent
  of @ARGV and whatever perl doesn't uses itself it places in @ARGV.



------------------------------

Date: Wed, 9 Apr 2008 02:43:26 -0700 (PDT)
From: ff0000 <ff0000.it@gmail.com>
Subject: Re: Trouble with @ARGV
Message-Id: <83cef5c2-93e6-459c-8d12-1d1563debb87@z38g2000hsc.googlegroups.com>

Hi Makholm,

Thanks for gonna be so fast :-)

> This would work:
>   ff0000@tsi00588pc:tmp$ ./test.pl '"a b c"'
Yes, this works nice...
So, I expand the question: if I want to parse a command line like
this:

$ perl_script.pl --option=value_1,value_2="a simple string, for
value_2"
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Do you think it's impossible to preserve the above marked quoting?
I mean "preserve it" without double quoting it or change somewhat
relative
to current shell setting (i don't want to force user habits :-)...

Bye.
ff0000


------------------------------

Date: Wed, 09 Apr 2008 12:37:16 +0200
From: Matija Papec <name@yahoo.com>
Subject: Re: Trouble with @ARGV
Message-Id: <fti68v$mtm$1@ss408.t-com.hr>

ff0000 wrote:
>> This would work:
>>   ff0000@tsi00588pc:tmp$ ./test.pl '"a b c"'
> Yes, this works nice...
> So, I expand the question: if I want to parse a command line like
> this:
> 
> $ perl_script.pl --option=value_1,value_2="a simple string, for
> value_2"
>  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Do you think it's impossible to preserve the above marked quoting?
> I mean "preserve it" without double quoting it or change somewhat
> relative
> to current shell setting (i don't want to force user habits :-)...

Perhaps you could look at @ARGV as a string, and set your own parsing rules.


my $aline = "@ARGV";
# ..
# remove leading "--", etc.

my %opt = map { split /=/ } split /,/, $aline;

use Data::Dumper;
print Dumper \%opt;


------------------------------

Date: Wed, 9 Apr 2008 04:03:51 -0700 (PDT)
From: ff0000 <ff0000.it@gmail.com>
Subject: Re: Trouble with @ARGV
Message-Id: <05b16027-3587-4a0f-a9e7-7d86fbb658ca@8g2000hse.googlegroups.com>

Hi,

> Perhaps you could look at @ARGV as a string, and set your own parsing rules.
>
> my $aline = "@ARGV";
> # ..
> # remove leading "--", etc.
>
> my %opt = map { split /=/ } split /,/, $aline;
>
> use Data::Dumper;
> print Dumper \%opt;
I can't split in such way, because i invoke this:

  $ perl_script.pl --option=value_1,value_2="a simple, string"

but to perl arrive this @ARGV:

  --option=value_1,value_2=a simple, string

and your dump isn't pretty good:

  $ ./test.pl --option=value_1,value_2="a simple, string"

  $VAR1 = {
            ' string' => undef,
            'value_2' => 'a simple',
            '--option' => 'value_1'
          };

:-|... Maybe i could avoid this mess (and take me to an easy
parsing) using a space separator instead of ','...

Thank you all! :-)
ff0000


------------------------------

Date: Wed, 9 Apr 2008 04:04:01 -0700 (PDT)
From: ff0000 <ff0000.it@gmail.com>
Subject: Re: Trouble with @ARGV
Message-Id: <66fe886c-2c58-42ca-93b1-037b19d0f4d5@p25g2000hsf.googlegroups.com>

Hi,

> Perhaps you could look at @ARGV as a string, and set your own parsing rules.
>
> my $aline = "@ARGV";
> # ..
> # remove leading "--", etc.
>
> my %opt = map { split /=/ } split /,/, $aline;
>
> use Data::Dumper;
> print Dumper \%opt;
I can't split in such way, because i invoke this:

  $ perl_script.pl --option=value_1,value_2="a simple, string"

but to perl arrive this @ARGV:

  --option=value_1,value_2=a simple, string

and your dump isn't pretty good:

  $ ./test.pl --option=value_1,value_2="a simple, string"

  $VAR1 = {
            ' string' => undef,
            'value_2' => 'a simple',
            '--option' => 'value_1'
          };

:-|... Maybe i could avoid this mess (and take me to an easy
parsing) using a space separator instead of ','...

Thank you all! :-)
ff0000


------------------------------

Date: Wed, 9 Apr 2008 04:05:55 -0700 (PDT)
From: ff0000 <ff0000.it@gmail.com>
Subject: Re: Trouble with @ARGV
Message-Id: <f54005ae-50c7-4ace-b2d3-758e7e96ad5b@m44g2000hsc.googlegroups.com>

Hi,

> Perhaps you could look at @ARGV as a string, and set your own parsing rules.
>
> my $aline = "@ARGV";
> # ..
> # remove leading "--", etc.
>
> my %opt = map { split /=/ } split /,/, $aline;
>
> use Data::Dumper;
> print Dumper \%opt;
I can't split in such way, because i invoke this:

  $ perl_script.pl --option=value_1,value_2="a simple, string"

but to perl arrive this @ARGV:

  --option=value_1,value_2=a simple, string

and your dump isn't pretty good:

  $ ./test.pl --option=value_1,value_2="a simple, string"

  $VAR1 = {
            ' string' => undef,
            'value_2' => 'a simple',
            '--option' => 'value_1'
          };

:-|... Maybe i could avoid this mess (and take me to an easy
parsing) using a space separator instead of ','...

Thank you all! :-)
ff0000


------------------------------

Date: Wed, 9 Apr 2008 04:13:19 -0700 (PDT)
From: ff0000 <ff0000.it@gmail.com>
Subject: Re: Trouble with @ARGV
Message-Id: <627c3512-b278-4d1c-9653-0f413b321429@m71g2000hse.googlegroups.com>

Hi,

> Perhaps you could look at @ARGV as a string, and set your own parsing rules.
>
> my $aline = "@ARGV";
> # ..
> # remove leading "--", etc.
>
> my %opt = map { split /=/ } split /,/, $aline;
>
> use Data::Dumper;
> print Dumper \%opt;
I can't split in such way, because i invoke this:

  $ perl_script.pl --option=value_1,value_2="a simple, string"

but to perl arrive this @ARGV:

  --option=value_1,value_2=a simple, string

and your dump isn't pretty good:

  $ ./test.pl --option=value_1,value_2="a simple, string"

  $VAR1 = {
            ' string' => undef,
            'value_2' => 'a simple',
            '--option' => 'value_1'
          };

:-|... Maybe i could avoid this mess (and take me to an easy
parsing) using a space separator instead of ','...

Thank you all! :-)
ff0000


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1434
***************************************


home help back first fref pref prev next nref lref last post