Learn PERL Basic with Me : Miles to Km converter PERL Script

Yesterday, I shared the first PERL script I have ever written. So for example, if you enter the name RAM That script will print Hi RAM, How are you today. Today's PERL script is a miles to km converter. So when you enter a value in miles it will convert it into Km.

Miles to km converter


# Km to miles converter

print "Please Enter the value in mile: ";

$mile = ;

# 1 mile = 1.609344 kilometers

$km = $mile * 1.609344;
print "Result: $km Kms \n";

break the code

  • Line 5 will ask for the value in miles
  • Line 5 whatever value you enter will be store as $mile
  • Line 11 Since 1 mile = 1.609344 kilometers therefore the value you entered (that is stored in $mile) will be multiplied (*) by 1.609344 and stored as $km
  • Line 13 Value of $km will be print

    1. Can you wright a PERL script to convert hours into minutes
    2. Can you wright a PERL script to convert days into hours

    No comments:

    Post a Comment

    Have Problem ?? Drop a comments here!