#!/usr/local/bin/perl
#
#  unshar - remove mail/news header and extract shar archive
#
if ($#ARGV < 0) {
	while (<STDIN>) {
		last if (/^#!/o);
	}
	open(SH, "| /bin/sh") || die "No shell";
	while (<STDIN>) {
		print SH;
	}
	close(SH);
} else {
	foreach $file (@ARGV) {
		open(FILE, "< $file") || die "Cannot read $file";
		while (<FILE>) {
			last if (/^#!/o);
		}
		open(SH, "| /bin/sh") || die "No shell";
		while (<FILE>) {
			print SH;
		}
		close(SH);
		close(FILE);
	}
}
exit 0;
