D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Perl "system or exec" commands into a var



On Thu, Jun 12, 2003 at 10:16:37AM +0100, Mark Cubitt wrote:

> is there a way I can execute a command with perl and put the output
> into a variable, I'm guessing this is quite easy but I can't find how
> to achive this. 

Yes, there are lots. The one you choose does rather depend on whether
or not you want to look at the return code or stderr of the external
program, or if you want to get a lot of data out, which you need to
buffer and, of course, if you need to pump it in.

The most simple way to do it is:

$var = `command`; # those are back ticks

HTH

Steve

PS There is a perl list :)

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly