From owner-freebsd-questions Sun Mar 24 12:47:25 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mobil.cz (diana.mobil.cz [194.228.200.160]) by hub.freebsd.org (Postfix) with ESMTP id 14F5A37B417 for ; Sun, 24 Mar 2002 12:47:18 -0800 (PST) Received: from ester.mobil.cz (ester.mobil.cz [194.213.62.23]) by mobil.cz (8.11.6/8.11.0) with ESMTP id g2OKlEH10753; Sun, 24 Mar 2002 21:47:15 +0100 Received: from roman.mobil.cz ([10.2.0.89]) by ester.mobil.cz (Lotus Domino Release 5.0.9a) with ESMTP id 2002032421470486:3625 ; Sun, 24 Mar 2002 21:47:04 +0100 Received: (from roman@localhost) by roman.mobil.cz (8.11.6/8.11.6) id g2OL19G03188; Sun, 24 Mar 2002 22:01:09 +0100 (CET) (envelope-from neuhauser@mobil.cz) X-Authentication-Warning: roman.mobil.cz: roman set sender to neuhauser@mobil.cz using -f Date: Sun, 24 Mar 2002 22:01:09 +0100 From: Roman Neuhauser To: "Brian T. Schellenberger" Cc: Charles Burns , ilia@chel.skbkontur.ru, questions@FreeBSD.ORG Subject: Re: Perl thing Message-ID: <20020324210109.GJ389@roman.mobil.cz> Mail-Followup-To: "Brian T. Schellenberger" , Charles Burns , ilia@chel.skbkontur.ru, questions@FreeBSD.ORG References: <20020324195045.EF418BA05@i8k.babbleon.org> Mime-Version: 1.0 In-Reply-To: <20020324195045.EF418BA05@i8k.babbleon.org> User-Agent: Mutt/1.3.26i X-MIMETrack: Itemize by SMTP Server on ester/Mobil(Release 5.0.9a |January 7, 2002) at 03/24/2002 09:47:04 PM, Serialize by Router on ester/Mobil(Release 5.0.9a |January 7, 2002) at 03/24/2002 09:47:13 PM, Serialize complete at 03/24/2002 09:47:13 PM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > From: Brian T.Schellenberger > To: "Charles Burns" , > 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