in reply to Breaking up a really long string

I had the same problem some time ago (I have IRC logs online, and too long words cause horizontal scrolling, which is evil, so I had to break up words), and I solved it roughly the same way as you did.

I can only add that it's a bad idea to use $&, because it will slow down regex matches in your whole script, and even in modules included from your script.

Use $var =~ s/(\S{$last_length})/$1\n/sg; instead.

Replies are listed 'Best First'.
Re^2: Breaking up a really long string
by almut (Canon) on Jun 23, 2008 at 21:57 UTC
    it's a bad idea to use $&

    Some more background as to why can be found here   (note to the OP — I'm sure you know :)

Re^2: Breaking up a really long string
by mhearse (Chaplain) on Jun 23, 2008 at 21:52 UTC
    Wow. Thanks for both of your posts. Unfortunately, I was unaware of the input/output record separators (which I'm ashamed to admit!). Thanks again.