Leave a comment

Comments 6

chaosinaskirt November 27 2007, 00:05:19 UTC
Poke at daoist on ST? He used to do a ton of perl programming.

Isn't string exec (string command [, string array [, int return_var]]) the function for executing a command?

Reply

lux_aeturna November 27 2007, 00:56:33 UTC
The problem with that is that exec() doesn't return the return value of the command, which I needed for this particular thing. What I wanted was 'system(string command)' and I can get everything else I need out of $?.

Reply

man perlfunc util November 27 2007, 02:02:22 UTC
The return value is the exit status of the program as returned
by the "wait" call. To get the actual exit value, shift right
by eight (see below). See also "exec". This is not what you
want to use to capture the output from a command, for that you
should use merely backticks or "qx//", as described in
"`STRING`" in perlop. Return value of -1 indicates a failure
to start the program or an error of the wait(2) system call
(inspect $! for the reason).

Reply

chaosinaskirt November 27 2007, 02:33:19 UTC
Ah, my first response would have been a cludgey pipe of the output and read in the file.

But I'm not a programmer (I just want to get the job done, not make it elegant) :p

Reply


Leave a comment

Up