I dont want to break by # of characters alone but by # of characters in a word.
like if a word is more than 30 chr long then, insert a dash and space after every 30th letter only in that word. if any words are not more than 30 chr. long then leave alone
i.e. "check out supercaliblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah and all other cool stuff"
to: "check out supercaliblahblahblahblahblahb- lahblahblahblahblahblahblahbla- hblahblahblahblah and all other cool stuff"
this space is so it will naturally wrap around.
If I cant do it in with a regex can i do it in an array?
I've tried for two weeks to no avail i keep inserting every 30 chr. regardless of words :(
any help would be appreciated!
John
my $foo = q[supercaliblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah];
print $foo."\n";
$foo =~ s¦(\w{30})¦$1- ¦g;
print $foo."\n";
[CTRL+C]
./test.pl
supercaliblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah
supercaliblahblahblahblahblahb- lahblahblahblahblahblahblahbla- hblahblahblahblah