in reply to output differs in perl version

I cant upgrade it to latest version, since i m running under my college server.

Surely not true. One doesn't need any special permissions to install Perl. It's even easy using App::perlbrew.

Any suggestion or modifications to achieve the same output in 5.8.8.

my $n = 0; while ( $str1 =~ /(\S+\s+)(?=(\S+\s+\S+))/g ) { print "$t1$t2\n"; ++$n; }
or
my @words = split ' ', $str; my $n = @words - 2; print "@words[$_+0, $_+1, $_+2]\n" for 0..$n-1;

This code works in perl 5.10.1.. but not in perl 5.8.8.

Although 5.8.8 is not giving the output you want, it's the one giving the correct output for the given code.