in reply to Re: Counting characters in a string
in thread Counting characters in a string

If you wish to avoid any modules, you can do it this way:
#!/usr/local/bin/perl use strict; use warnings; my $var = "this is just a sample of a string, there is nothing really +important in the scalar, just a lot of text"; my $pos = 9; while(( $pos = index($var, ' ', $pos)) > -1 ) { substr($var, $pos, 1) = "\n"; $pos += 10; } print "\n$var\n";
Just remember, TIMTOWTDI.

- - arden.