in reply to not able to get the output using split function

That ungainly "C-style" for loop, can be made much more perlish as follows:
use Modern::Perl '2011'; my $sentence = 'aaaa bbb ccc'; my @words = split(/\s+/, $sentence); my $i; while (my ($i, $word) = each @words) { say "$i: $word"; }
Note: it will need at least Perl 5.012 to work.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics