The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/local/bin/perl
# 'arch' for the Perl Power Tools project,
#  By: Theo Van Dinter (felicity@kluge.net)
#
# It's sad, the docs are longer than the code...
# $Id: arch,v 1.2 2004/08/05 14:17:43 cwest Exp $

use POSIX qw(uname);
$arch=(uname())[4]; # machine ... (uname -m)
$system=(uname())[0]; # system ... (uname -s)

# sun3.* -> sun3, sun4.* -> sun4, etc. SunOS hooey.
# looks like `uname -m` eq `arch -k` on suns ...
unless ( $ARGV[0] =~ /^-k$/i ) {
	$arch=~s/^(sun\d+).*$/$1/;
}

$arch = "$system.$arch" if ( $system eq "OpenBSD" ); # OpenBSD hooey.
print "$arch\n";

=head1 NAME

arch - display system machine type

=head1 SYNOPSIS

B<arch> [ C<-k> ]

=head1 DESCRIPTION

arch displays the current system architecture type.  It tends to be
equivilent to C<uname -m> (except on SunOS platforms, see B<NOTES>).

=head1 OPTIONS

C<-k>	Displays kernel architecture on SunOS platforms.

=head1 NOTES

SunOS tends to differentiate between kernel and system architecture.  I<uname
-m> will return kernel architecture.  System architecture is the same
information except it doesn't include the trailing alpha chars.  I.e.:
'sun4m' (kernel) = 'sun4' (system), 'sun3x' = 'sun3', etc, etc.

=head1 HISTORY

Perl version rewritten for the Perl Power Tools project from the
description of the arch program in OpenBSD.

=head1 AUTHOR

Theo Van Dinter (felicity@kluge.net)

=head1 SEE ALSO

uname(1) uname(2) machine(1)