Re: parsing command line args



Ben Morrow <benmorrow@xxxxxxxxxxxxx> wrote:

Quoth "badarisj@xxxxxxxxx" <badarisj@xxxxxxxxx>:
folks,

when i give a command-line of:
/tmp/test.pl -arg1 -arg2 -arg3 'value with spaces'
to unix-shell, my perl script has access to the command-line arguments
in the following neat array:

0 ARRAY(0x12b06c)

I'm not quite sure what you intended to mean by this line: for a start,
@ARGV certainly doesn't have two 'element 0's.


That's what caused me to not attempt an answer when I saw it.


The Text::ParseWords module will do this for you. I was fairly sure this
was in the FAQ, but a couple of reasonable searches didn't find it,


perldoc -q split

How can I split a [character] delimited string except when inside [character]?


--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.



Relevant Pages

  • Re: parsing command line args
    ... my perl script has access to the command-line arguments ... in the following neat array: ... any ideas on parsing the $cmd_str into a @ARGV array i have shown ...
    (comp.lang.perl.misc)
  • Re: Perl script finds module in Terminal but not as CGI?
    ... Why would Perl script on the command-line find it but not a CGI executable? ... installed Date::Manip so my normal bash shell is picking it up. ... Got to rewrite a bit of code now (rather have it portable than tied in to only Macs with Fink). ...
    (uk.comp.sys.mac)
  • Re: parsing command line args
    ... my perl script has access to the command-line arguments ... in the following neat array: ... parsing of the command-line by many unix shells (which is exactly ...
    (comp.lang.perl.misc)
  • parsing command line args
    ... to unix-shell, my perl script has access to the command-line arguments ... in the following neat array: ...
    (comp.lang.perl.misc)
  • Desparate, tired programmer -- bug in perl5.6.1/apache1.3.31 ?
    ... anyone know why a Perl script that runs perfectly from the command-line ... will silently refuse to write to its data file when called ... from PHP using the systemcommand? ...
    (comp.lang.perl.misc)