Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Mar 2002 22:01:09 +0100
From:      Roman Neuhauser <neuhauser@mobil.cz>
To:        "Brian T. Schellenberger" <bts@babbleon.org>
Cc:        Charles Burns <burnscharlesn@hotmail.com>, ilia@chel.skbkontur.ru, questions@FreeBSD.ORG
Subject:   Re: Perl thing
Message-ID:  <20020324210109.GJ389@roman.mobil.cz>
In-Reply-To: <20020324195045.EF418BA05@i8k.babbleon.org>
References:  <F140eOdU8uudgUWr81n000207c8@hotmail.com> <20020324195045.EF418BA05@i8k.babbleon.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> From: Brian T.Schellenberger <bts@babbleon.org>
> To: "Charles Burns" <burnscharlesn@hotmail.com>,
> 	ilia@chel.skbkontur.ru, questions@FreeBSD.ORG
> Subject: Re: Perl thing
> Date: Sun, 24 Mar 2002 14:50:45 -0500
> 
> On Sunday 24 March 2002 02:46 pm, Charles Burns wrote:
> | IANAPP (Perl Programmer) but I know that Perl is great for text parsing.
> | One way that you could do this, though it wouldn't exactly be elegant,
> | would be to parse the output of (say) dmesg. Surely though, there are
> | better ways.
> |
> | >Dear Sirs,
> | >
> | >is there anything that I could use it in perl program like I can write in
> | >C:
> | >
> | >#ifdef __FreeBSD__
> | >
> | >#endif
> | >
> | >???
> | >
> | >I want to port some perl program that it could run either on FreeBSD or
> | >any other system...
> 
> Howzabout
> 
>    if ($ENV{'OSTYPE'} eq 'FreeBSD') {
>    }
> 
> I'm not an expert on this; I just did a printenv | grep BSD and both OSTYPE 
> and HOSTTYPE are set to FreeBSD.  I'm not sure if that's always the case, but 
> I do know that it's always the case that you can use $ENV to get to 
> environment variables.
> 
> I also checked, and these are set for root and for a from-scratch user 
> account, so they are probably safely universal.

    also:

    roman@roman ~ > perl -e '$x = `uname`; print $x;'
    FreeBSD

    perlport(1):

          Unix

       Perl works on a bewildering variety of Unix and Unix-like
       platforms (see e.g. most of the files in the hints/
       directory in the source code kit).  On most of these
       systems, the value of $^O (hence $Config{'osname'}, too)
       is determined by lowercasing and stripping punctuation
       from the first field of the string returned by typing
       uname -a (or a similar command) at the shell prompt.
       Here, for example, are a few of the more popular Unix
       flavors:

           uname        $^O        $Config{'archname'}
           -------------------------------------------
           AIX          aix        aix
           FreeBSD      freebsd    freebsd-i386
           Linux        linux      i386-linux
           HP-UX        hpux       PA-RISC1.1
           IRIX         irix       irix
           OSF1         dec_osf    alpha-dec_osf
           SunOS        solaris    sun4-solaris
           SunOS        solaris    i86pc-solaris
           SunOS4       sunos      sun4-sunos

       Note that because the $Config{'archname'} may depend on
       the hardware architecture it may vary quite a lot, much
       more than the $^O.


-- 
FreeBSD 4.4-STABLE
9:54PM up 5:40, 12 users, load averages: 0.01, 0.06, 0.04

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020324210109.GJ389>