#!/usr/local/bin/perl

# 
# perlsh: Perl shell mode
# 
#     Oct.11,'95. OSHIRO Naoki.
# 
#     $Log:$
#

#
# Parameter Settings
#
$pi=atan2(1,1)*4;

#
# Main routine
#
while (<>) {
	s/(SIN|COS|r2d|d2r|TAN|ATAN2)/&\1/g;
	if (/;\s*$/) {
		eval($_);
	} else {
		print eval($_), "\n";
	}
}

#
# Subroutines
#

# deg <--> rad convertion
sub d2r {return @_[0]*$pi/180;}
sub r2d {return @_[0]*180/$pi;}

# tan
sub tan {return &sin(@_[0])/cos(@_[0]);}

# Trigometric functions for degree parameter
sub SIN {return sin(&d2r(@_[0]));}
sub COS {return cos(&d2r(@_[0]));}
sub TAN {return (&SIN(@_[0])/&COS(@_[0]));}
sub ATAN2 {return &r2d(atan2(@_[0], @_[1]));}
  
#
# end of perlsh here, folks!
#
