Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: loop inside system command

by cidaris (Friar)
on Jul 17, 2002 at 14:18 UTC ( #182432=note: print w/replies, xml ) Need Help??


in reply to loop inside system command

I got this to work:
my $command_line = ""; my $first_build = "hi.bld"; my @other_builds = qw( low.bld hello.bld cow.bld ); $command_line = "c:\\execu $first_build"; $command_line .= " " . shift @other_builds while (@other_builds); $command_line .= " file.c"; print "$command_line\n"; system "$command_line\n";


Hope it helps.
cidaris

Replies are listed 'Best First'.
Re: Re: loop inside system command
by RMGir (Prior) on Jul 17, 2002 at 15:07 UTC
    Interesting, cidaris. But have you ever used the join command?

    It would save you your loop on "while(@other_builds)".

    $command_line = "c:\\execu $first_build "; # note trailing space $command_line .= join " ", @other_builds; $command_line .= " file.c";
    The only downside here is that you wind up with 2 spaces between $first_build and file.c if there are no other_builds.

    The problem goes away if you do everything in a join:

    $command_line .= join " ", ("c:\\execu $first_build",@other_builds,"fi +le.c");

    --
    Mike

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://182432]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2023-03-22 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?