=begin metadata

Name: arch
Description: display system machine type
Author: Theo Van Dinter, felicity@kluge.net

=end metadata


use strict;
use POSIX qw(uname);

# system ... (uname -s)
# arch   ... (uname -m)
my ($system, $arch) = (uname())[0,4];

# 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


B<arch> [ C<-k> ]


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)