On 13 Jun 2001 13:39:49 -0400, Craig S Monroe wrote:
> Chris,
> I appreciate you responding to my message, but I don't understand some of
> the
> issues you were speaking about.
>
> "you want to use backticks " I do not understand what you mean by this?
> Where should I be using them? In place of what?
<snip />
> > There are two things wrong here. First system returns the exit code of
> > the process you call (not the output), you want to use backticks (shift
> > ~ on most keyboards in the US). Second =~ is the binding operator for
> > regexps not the assignment operator. You should be saying:
> >
> > $time = `TIME /T`;
> > $date = `DATE /T`;
> >
<snip />
There are three ways to execute an external program in Perl: exec,
system,
and backticks. Exec replaces the currently running process with the new
program. System (which is actually a fork followed by an exec) runs the
the named program. In both cases all output goes to the standard
output,
normally your screen. NOTE: if you redirect stdout in your program (ie
*stdout = *somefile;) it will have NO EFFECT on exec and system. The
third
way to run a command is to put the command in backticks like this:
$return_value = `DATE /T`;
This runs the named program and returns what would have gone to stdout.
NOTE: if the program writes to the stderr it will NOT be returned unless
you redirect stderr to stdout like this
$return_value = `somecommand 2>&1`; #NOTE: this only works in unix,
sorry.
Please let me know if this didn't help.
--
Today is Prickle-Prickle, the 18th day of Confusion in the YOLD 3167
Or is it?