on Thu, 15 Aug 2002 08:40:16 GMT, Shivani wrote: > my $line="abcdefgh"; > > i want output which has 8 lines: > 1st outline: abcdefgh > 2nd outline:ab bc cd de ef fg gh > 3nd outline:abc bcd cde def efg fgh > 4th outline.......so on > > please let me know the shortest code tp perform this. i can run it > but lot of code.. > thanks!
The shortest code is not always the clearest. I would use this: #! perl -w use strict; my $line="abcdefgh"; my $len = length($line); for my $i (2..$len) { for my $j (0..$len-$i) { print substr($line, $j, $i), $j != $len-$i ? " " : "\n"; } } -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]