Getting the platform on which Perl is running 
Author Message
 Getting the platform on which Perl is running

Hi,

Does anybody know if there is a way (a standard function or some
predefined variable) to ask Perl on what platform it is running?

Thanks in advance,

Hans Scholte



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running


Quote:
> Hi,

> Does anybody know if there is a way (a standard function or some
> predefined variable) to ask Perl on what platform it is running?

From perlfaq8:

"How do I find out which operating system I'm running under?"

The $^O variable ($OSNAME if you use English) contains the operating system
that your perl binary was built for.

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running
$^O


Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running

Quote:

>> Does anybody know if there is a way (a standard function or some
>> predefined variable) to ask Perl on what platform it is running?
>The $^O variable ($OSNAME if you use English) contains the operating system
>that your perl binary was built for.

"was *built* for". It does not say waht OS it is actually running on,
which is a major limitation. Well... it's not a limitation on Unixy
platforms, where people always compile their own programs. But on
Windows, you cannot distinuish between Window 95 or NT4, for example.
All it says, is "Win95".

What you could do on Windows, is use the Win32::API module, and using
the GetVersion or GetVersionEx API calls, you can get details of what
platform the script is running on.

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running

Quote:

> Does anybody know if there is a way (a standard function or some
> predefined variable) to ask Perl on what platform it is running?

Type 'perldoc perlvar' at your command prompt for a list of all the
built-in variables and what they mean. The one you want is $^O ($OSNAME
under 'use English').

-mjc



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running
If it is on a Unix system you should be able to do something like

$OS = `uname`;
print $OS;

notice that in the first line they are back ticks telling perl to execute
the system command and store the return in $OS.

Hope this helps
Jason Malone


Quote:
> Hi,

> Does anybody know if there is a way (a standard function or some
> predefined variable) to ask Perl on what platform it is running?

> Thanks in advance,

> Hans Scholte



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running
[ Please put your comments following the quoted text that you
  are commenting on.  Jeopardectomy performed.                   ]


Quote:


> > Does anybody know if there is a way (a standard function or some
> > predefined variable) to ask Perl on what platform it is running?

Have you considered looking at the list of predefined varables?  It is
not exactly long - surely is would be quicker to read it than post to
Usenet asking if it contains something?

Quote:
> If it is on a Unix system you should be able to do something like

> $OS = `uname`;
> print $OS;

Usually $^O is enough.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running
What about NT? It does not recognise the uname command. How can you
tell if a perl script is running in a unix/nt platform. Is there 1
variable/function that you can use?

Quote:

> [ Please put your comments following the quoted text that you
>   are commenting on.  Jeopardectomy performed.                   ]




> > > Does anybody know if there is a way (a standard function or some
> > > predefined variable) to ask Perl on what platform it is running?

> Have you considered looking at the list of predefined varables?  It is
> not exactly long - surely is would be quicker to read it than post to
> Usenet asking if it contains something?

> > If it is on a Unix system you should be able to do something like

> > $OS = `uname`;
> > print $OS;

> Usually $^O is enough.

> --
>      \\   ( )
>   .  _\\__[oo

>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\

Sent via Deja.com http://www.deja.com/
Before you buy.


Wed, 18 Jun 1902 08:00:00 GMT  
 Getting the platform on which Perl is running

Quote:
> What about NT? It does not recognise the uname command.

and then quotes an extensive history of the thread, including sigs,
but in particular these key lines:

Quote:
> > > $OS = `uname`;
> > > print $OS;

> > Usually $^O is enough.

This is the thing about upside-down quoters, they never seem to read
what they're quoting.  I'm seriously considering killfiling the lot of
them.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. A Perl Script Runs on Different Platforms

2. Perl runs slowly on Win32 platform...

3. Running same perl script on different platforms

4. running a cgi/perl program every 7 am?

5. getting file properties (version etc) on Windows platform

6. Why am I getting an error with @_ ?

7. Why am I getting this regexp error?

8. Why am I getting an undefined subroutine error?

9. Running the same scripts of different platforms

10. Why am I running out of memory?

11. Which Win32 OS am I running?

12. HOw can I tell the line number of the expression I am running in a

 

 
Powered by phpBB® Forum Software