#!/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";