I am a beginner, so beware.
When I do this, I would do:
my $ipconfig = `ipconfig /renew`;
my $ipcfg_success = $?;
if ($ipcfg_success == 0) {
do something;
} else {
do something;
}
or, to test:
my $ipconfig = `ipconfig /renew`;
my $ipcfg_success = $?;
die "command failed: $?" unless $ipcfg_success == 0;
If these are wrong, please say so, so I don't do them again ;-)
But remember, $? is the status returned by the last pipe close, backtick (``) command, successful call to wait() or waitpid(), or from the system() operator. Therefore, be careful where you put it, i.e. don't define it at the top of your program and expect it to work.
For $? see perlvar and for other ways to execute commands, see exec and system functions.
Thanks.
Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.