#!/usr/local/bin/perl use strict; use warnings; my $input; my $hrate = 0; my $yrate = 0; while (!defined $input) { print "\nDo you wish to calculate yearly salary (y) or hourly rate (h)?"; chomp ($input = ); if ($input =~ /h/i) { print "\nEnter your yearly salary:"; chomp ($yrate = ); $hrate = ($yrate / 52) / 40; print "\nYour hourly rate is $hrate"; }elsif ($input =~ /y/i) { print "\nEnter your hourly rate:"; chomp ($hrate = ); $yrate = ($hrate * 40) * 52; print "\nYour yearly salary is $yrate"; }elsif ($input =~ /q/i) { exit; }else { print "\nError in input"; } undef $input; #to continue in the loop }