perl -e'while(1){print"enter h/y:";$_=<>;next unless/^[hy]$/;($s,$m)=/h/?(yearly,2080):(hourly,1/2080);print"enter rate:";$_=<>;print"your $s rate is ",$_*$m,$/}' # or expanding the same idea into a proper program #!/usr/bin/perl use strict; use warnings; my $hours=40*52; # are you mad ? while(1){ print 'Do you wish to calculate yearly salary (y) or hourly rate?(h): '; chomp($_=<>); last unless $_; next unless/^[hy]$/; my @words=("yearly salary", "hourly rate"); my ($ask, $say,$multiplier)=/y/?(1, 0, $hours):(0, 1, 1/$hours); print "Enter your $words[$ask]: "; $_=<>; print"your $words[$say] is ", $_*$multiplier, "\n\n" }