Practice Set 6





1) what is the output :

$line="Hello";

for($a=0  ;   $a < length($line) ; $a ++)
{
    print substr($line,  $a  ,  length($line) -$a ) , "\n";
}


2) what is the output:

$line="Hello";

for($a= length($line) - 1  ;   $a >=0 ; $a --)
{
    print substr($line,  $a  ,  1 ) , "\n";
}



3) what is the output:

$line="Hello";
$line = ~     tr/aeiou/12345;
print "$line\n";

4) what is the output:

$line="Hello";
$line = ~     tr/a-z/A-Z/;
print "$line\n";


5) Write a complete perl program that will a date give in mm/dd/yyyy format and output the date as

Month : mm
Day : dd
Year : yyyy

Input should come from the keyboard. A sample run of this program might look like this:

Please enter date        <--program prompt
12/23/1987                 <--user types this in
Month: 12                   <-- program types these 3 lines
Day : 23
Year : 1987