in reply to Re: how to Insert a newline character in a sentence
in thread how to Insert a newline character in a sentence

Try this
while (<DATA>) { $var=$_; $var=~s/(.{10})/$1\\n/; print "$var"; } __DATA__ dgbjhdghjdfgjhd dfgjdjfghjkdhgdfg dgbhgdfjgjhgdfgdfg ghgjgglhkdjghkdhgk

Replies are listed 'Best First'.
Re^3: how to Insert a newline character in a sentence
by ig (Vicar) on Jul 24, 2009 at 07:39 UTC

    update: Or, to insert newlines at the 10th position and avoid double spacing lines of 9 characters, perhaps this

    use strict; use warnings; while (<DATA>) { my $var=$_; $var=~s/(.{9})/$1\n/; print "$var"; } __DATA__ dgbjhdghjdfgjhd dfgjdjfghjkdhgdfg dgbhgdfjgjhgdfgdfg ghgjgglhkdjghkdhgk