I really appreciate everyone's help here but I'm clearly not being clear. That's my fault and I've already punnished my wicked flesh for wasting everyone's brain cells. Let me try being a bit more explicit...

I'm writing a cron daemon in Perl.

O.K. not really, but sort of. At this point most people should be ready to ask "Why would you want to do something like that?" and the answer is basically, they want to pay me for it (could be worse, they could want me to encode everything Encoding Script).

So, this cron daemon does everything serially so I don't need to worry about any time specifiers, I just have the programs to run in a text file (crontab sort of thing). An entry might look like.

"getStuff" configs --force=all --out out.txt -v -a
I'm going to want to pass this to system() at some point and I'm having a problem just passing in the complete line. I keep getting
'D:\Documents' is not recognized as an internal or external command, operable program or batch file.
Yes. Windows. I've punnished my flesh for that too.

Here is a simple example of what I want.

while (<DATA>) { chomp; s/#.*$//; #Clear out comments next unless $_ && $_ ne ''; m/^\s+\Q"\E(.+?)\Q"\E\s*(.*$)/; $task = $1; @args = split /\s+/, $2 if $2; for (my $i = 0; $i < $#args; $i++) { #Arguments begin with - or -- or + if ($args[$i] =~ /^[-\+]/) { #if this looks like an argument, and the next one # doesn't, prepend the next thing to this one. $args[$i] .= " " . $args[$i+1] if $args[$i+1] =~ /^[^-\+]/; #remove the thing from the args array. splice @args, $i+1, 1; } } system ($task, @args); }
This seems to work. Well the thing I snipped it from seems to work but I might have screwed it up pasting it in here.
I keep thinking that there is probably a better way of doing this, but I can't seem to come up with one.

If anyone has any suggestions...
Thanks,
Ira

"We demand rigidly defined areas of doubt and uncertainty!"
~Vroomfondel (Hitch Hickers Guide to the Galaxy)


In reply to Re: join this by IraTarball
in thread splitting command-line arguments by IraTarball

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.