#!/usr/bin/perl -w
# Because blammage is important -- Phil
$target = $ARGV[0];
$oldblam = "blam-old";
#$blam = `$oldblam`;
$blam = `cat blam-asciiart`;
if($target)
{
	# Blam someone or something in particular
	if($target =~ /[a-z]{2,4}[0-9]{3,4}/)
	{
		# Someone
		if(`users | grep $target`) # Could use massfinger, but that's too slow
		{
			# Logged on
			$dudedoingtheblamming = $ENV{'USER'};
#			`echo "You've just been blammed by $dudedoingtheblamming." | write $target`;
			open(SHONKYSHONKYPERL, "|write $target");
			print SHONKYSHONKYPERL "$blam You've just been blammed by $dudedoingtheblamming. Have a nice day.\n";
			close SHONKYSHONKYPERL;

			print "Blammage sent.\n";
		}
		else
		{
			# Not logged on
			print "What a shame. $target isn't logged on to this machine at the moment.\nTry blamming them in person, or over e-mail.\n";
		}
	}
	else
	{
		# Something (todo)
		print "blam: Not enough anchovies.\n";
	}
}
else
	{exec $oldblam;} # If no parms, do old blammage
