Tuesday, November 30, 2010

WAP to print each character in the word hello in separate lines?

Perl Script:


#!/usr/bin/perl5.8.8

my $word="hello";
chomp($word);
my $l=length($word);
chomp($l);
my $i;
for ($i=0; $i<= $l; $i++)  {
my $x = substr($word,$i,1);
print "$x \n";
}



OUTPUT:
h
e
l
l
o

No comments:

Post a Comment