[EMAIL PROTECTED] wrote:
> Hi,
> 
> 
> 
>   I'm trying to accomplish some task using perl. So let
> 
>   me describe what I have.
> 
> 
> 
>   I have several systems of the following:
> 
> 
> 
>   Unix:
> 
>             Sun - Solaris
> 
>             HP - HPUX
> 
> 
> 
>   Windows:
> 
>             Dell - Windows 2k
> 
> 
> 
> 
> 
>  Each of these OS's have specific commands that are specific
> 
>  not only to the OS but to the hardware as well. Wouldn't it be
> 
>  better if I created a header file that contains these commands
> 
>  and assigned them to a common variable?
> 
> 
> 
>  Example:
> 
> 
> 
>             $memory = 'prtconf | grep Memory | awk '{print $3}'
> 
> 
> 
>  That would be the command that would be executed only if OS
> 
>  is Solaris.
> 
> 
> 
>  Here is my thinking on this:
> 
> 
> 
>  In one file I will have a list of the commands:
> 
> 
> 
> Example:
> 
> 
> 
>             os_commands.pl
> 
> 
> 
>             with in that file have the following:
> 
> 
> 
>             # memory command for Solaris
> 
>             $memory = 'prtconf | grep Memory | awk '{print $3}'
> 
> 
> 
> 
> 
>             # memory command for HPUX
> 
>             $memory = 'adb -k /stand/vmunix /dev/mem'
> 
> 
> 
>             list of other commands for other OS's.
> 
> 
> 
> Then have the main perl program call those memory variables based
> 
> on that setting into the main perl code.
> 
> 
> 
> So what you end up having is:
> 
> 
> 
> 1 file called command_header.pl which only list all the
> possible commands
> 
> 2. file will be the main perl code that just call or
> displaces the command
> within
> 
>     the perl
> 
> 
> 
> I'd appreciate the feedback if any.

This sounds fine in principle. Many of the standard Perl modules do this
kind of thing. You use the built-in $^O variable to detect the operating
system. If you want to see an example, do 'perldoc -m Cwd' to browse the
source code of the Cwd module.

Instead of command_header.pl, consider making a full-fledged module. It
isn't hard. Start by reading 'perldoc perlmod'.

Also, read 'perldoc perlport' for general info on writing cross-platform
perl.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to