Sys::Info::OS(3pm)

πŸ’– NAME πŸ’–

Sys::Info::OS β€” detailed os information. That's the whole vibe. Also hi, this is a <cyan>3pm</cyan> page, dropped by the User Contributed Perl Documentation girlies.


✨ VERSION ✨

This is version 0.7810, bestie. Write it down. πŸŽ€


🌸 SYNOPSIS 🌸

Okay so you can grab it two ways. Route one, through the big parent module:

use Sys::Info;
my $info = Sys::Info->new;
my $os   = $info->os(%options);

Or route two, straight in, no middleman:

use Sys::Info::OS;
my $os = Sys::Info::OS->new(%options);

Example:

use Data::Dumper;

warn "Collected information can be incomplete\n" if $os->is_unknown;

my %fs = $os->fs;
print Data::Dumper->Dump([\%fs], ['*FILE_SYSTEM']);

print "B1ll G4teZ rull4z!\n" if $os->is_windows;
print "Pinguin detected!\n"  if $os->is_linux;
if ( $os->is_windows ) {
   printf "This is a %s based system\n", $os->is_winnt ? 'NT' : '9.x';
}
printf "Operating System: %s\n", $os->name( long => 1 );

my $user = $os->login_name( real => 1 ) || $os->login_name || 'User';
print "$user, You've Got The P.O.W.E.R.!\n" if $os->is_root;

if ( my $up = $os->uptime ) {
   my $tick = $os->tick_count;
   printf "Running since %s\n"   , scalar localtime $up;
   printf "Uptime: %.2f hours\n" , $tick / (60*60      ); # probably windows
   printf "Uptime: %.2f days\n"  , $tick / (60*60*24   ); # might be windows
   printf "Uptime: %.2f months\n", $tick / (60*60*24*30); # hmm... smells like tux
}

πŸ¦‹ DESCRIPTION πŸ¦‹

It supplies detailed operating system information. Like, the whole tea on your OS. πŸ«–


πŸŽ€ NAME πŸŽ€

(Not me putting a second <pink>NAME</pink> section here β€” the original really does, and I respect the chaos. πŸ’€)

Sys::Info::OS - Detailed os information.


πŸ”₯ METHODS πŸ”₯

πŸ’œ new

Object constructor. It makes you an object. Main character energy from day one.

πŸ’œ name

Returns the OS name. Supports these named parameters: edition, long:

# also include the edition info if present
$os->name( edition => 1 );

This will return the long OS name (with build number, etc.):

# also include the edition info if present
$os->name( long => 1, edition => 1 );

πŸ’œ version

Returns the OS version.

πŸ’œ build

Returns the OS build number or build date, depending on the system. So like... could be a number, could be a date. Whichever the system feels like handing over. 🀷

πŸ’œ uptime

Returns the uptime as a unix timestamp.

πŸ’œ tick_count

Returns the uptime in seconds since the machine booted. Yes, seconds.

πŸ’œ node_name

Machine name.

πŸ’œ domain_name

Returns the network domain name.

Synonyms:

  • workgroup

πŸ’œ login_name

Returns the name of the effective user. Supports parameters in "name => value" format. Accepted parameters: real:

my $user = $os->login_name( real => 1 ) || $os->login_name;

πŸ’œ ip

Returns the IP number.

πŸ’œ fs

Returns an info hash about the filesystem. Heads up though β€” the contents of the hash can vary among different systems. So don't get comfy. πŸ™ˆ

πŸ’œ host_name

(no description, she's just there, living her life πŸ’…)

πŸ’œ time_zone

(also just vibing, no blurb)

πŸ’œ product_type

(no blurb, mystery woman ✨)

πŸ’œ bitness

If successful, returns the bitness ( 32 or 64 ) of the OS. Returns false otherwise.

πŸ’œ meta

Returns a hash containing various informations about the OS.

πŸ’œ cdkey

(no description given, iconic silence)

πŸ’œ locale

(no description given either β€” the audacity, honestly)


⭐ UTILITY METHODS ⭐

These are some useful utility methods. Little helper besties. 🫢

🌈 is_windows

Returns true if the os is windows.

Synonyms:

  • is_win32
  • is_win

🌈 is_winnt

Returns true if the OS is a NT based system (NT/2000/XP/2003).

Always returns false if you are not under windows or you are not under a NT based system.

🌈 is_win95

Returns true if the OS is a 9x based system (95/98/Me).

Always returns false if you are not under Windows or Windows9x.

Synonyms:

  • is_win9x

🌈 is_linux

Returns true if the os is linux.

Synonyms:

  • is_lin

🌈 is_bsd

Returns true if the os is (free|open|net)bsd.

🌈 is_unknown

Returns true if this module does not support the OS directly. (Sad girl hours. 😭)

🌈 is_root

Returns true if the current user has admin rights. πŸ‘‘

Synonyms:

  • is_admin
  • is_admin_user
  • is_adminuser
  • is_root_user
  • is_rootuser
  • is_super_user
  • is_superuser
  • is_su

πŸ’€ CAVEATS πŸ’€

Okay this is the part where we sit down. Real talk.

  • I don't have access to all operating systems in the world, so this module (currently) only supports Windows, Linux and (Free)BSD. Windows support is better. If you want support for some other OS, you'll need to write the driver yourself. Anything other than natively supported systems will fall-back to the generic "Unknown" driver which has very limited capabilities.
  • Win32::IsAdminUser() implemented in 5.8.4 (However, it is possible to manually upgrade the "Win32" module). If your ActivePerl is older than this, "is_admin" method will always returns false. (There may be a workaround for that).
  • Contents of the filesystem hash may change in further releases. Don't build your whole personality on it.
  • Filesystem [Windows]

File system information can not be extracted under restricted environments. If this is the case, we'll get an access is denied error.

  • Bitness has some problems [Linux, BSD], especially on the os side.
ngl bestie, that last one lives rent free in my head. "especially on the os side." periodt. πŸ’…

🌟 SEE ALSO 🌟

Go read these too, they're the friends of this page:


πŸ‘‘ AUTHOR πŸ‘‘

Burak Gursoy β€” the legend herself. 🫑


This software is copyright (c) 2006 by Burak Gursoy.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page, mwah πŸ’‹ this one shipped out with perl v5.40.1, dated 2025-10-07, and it's Sys::Info::OS(3pm) β€” go forth and <rainbow>slay</rainbow> responsibly πŸ¦‹βœ¨

πŸ“¦ where this page comes from