On 12/21/2006 09:05 AM, Tom Smith wrote:

I try to avoid calling console commands because there tends to be differences in some of the CLI utilities between distributions--that was actually one of the first things I had considered doing, except with the `groups` command.



You could limit or control the problems created by using console commands by putting all of the console commands into a single module, e.g.

----in file Myapp/Commands.pm-----
package Myapp::Commands;
$cmd{groups} = 'id -Gn ';
$cmd{users} = 'users ';
$cmd{who} = 'who ';


----in scripts that need to use those commands---
use MyApp::Commands;
my $groups = `$Myapp::Commands::cmd{groups} $ARGV[0]`;
my @groups = $groups =~ /(\w+)/g;

-----end----

That's similar to what Configure does when a GNU program is being complied--except that Gmake does not support packages :-)



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to