my $c; my $test="This is a test string"; for ( my $i = 0; $i < length($test); $i++ ) { $c = substr( $test, $i, 1); print "Character #",$i," = ",$c," from string ",$test,"\n"; } for (my $len = 1; $len <= length($test); $len++) { for ( my $i = 0; $i < length($test); $i++ ) { $c = substr( $test, $i, $len); print "String of length ",$len, " string at ",$i," = ",$c," from string ",$test,"\n"; } }