Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: how do i add a switch to executable

by andreychek (Parson)
on Jul 03, 2001 at 21:11 UTC ( #93585=note: print w/replies, xml ) Need Help??


in reply to how do i add a switch to executable

Well, assuming that you are still looking to use the 'system' function that we talked about yesterday, you would simply do:
my @args = ("deltree", "/y", 'c:\pathname') system(@args) == 0 or die "system @args failed: $?";
However, since you did ask about a very similar question yesterday, you really should get into the habit of reading the documentation. Perl comes with a lot of good docs, and they're also available on the web. Looking up the system command in the documentation willl yield all this and more. But of course, if you ever have trouble understanding anything you read, or aren't sure where to look, by all means ask. Good luck!
-Eric

Update: With tachyon's suggestion, I changed the quotes in the @arg variable for the pathname from double to single quotes, to keep \p from interpolating into something interesting that we don't really want :-) Thanks, tachyon++

Replies are listed 'Best First'.
Re: Re: how do i add a switch to executable
by tachyon (Chancellor) on Jul 03, 2001 at 21:37 UTC

    You probably want to change the double quotes around "c:\pathname" to single quotes 'c:\pathname' to supress interpolation of the \p. You can also call programs using backtics for example:

    $flg = "/?"; $dir =`dir c: $flg`; print $dir;

    You will note that the help flag /? has been interpolated into the backtics so that the command executed is the same as:

    C:\>dir c: /?

    The output is captured into $dir which we then print. As a general rule it is much better (read more secure, more reliable, more portable, perhaps faster) to use inbuilt perl functions than backtics or system.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n\w+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://93585]
help
Chatterbox?
[choroba]: BTW, both the bands I play in performed on Friday (at the same event). Quite an exhausting experience.
[Corion]: choroba: Ooof! I can imagine that ;)
[Corion]: I think at a Perl workshop some years ago I gave two talks on the same day and after that decided to only submit one talk per event ;)
[LanX]: you play the triangle, right?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-03-27 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.