in reply to Formatting text, eg long lines

It looks like you could use a simple regular expression. Try the following:
use strict; my $data = do {local $/; <DATA>}; # Will wrap lines longer then 50 characters $data =~ s{(.{50})(?=.)}{$1\n}g; print $data; __DATA__ ip_tables 9688 3 iptable_mangle,iptable_nat,iptable_fil +ter x_tables 8964 17 xt_CONNMARK,xt_length,xt_tcpudp,ipt_d +scp,ipt_ipp2p,xt_connmark,ipt_multiport,xt_state,ipt_TOS,xt_CLASSIFY, +ipt_ACCOUNT,ipt_MASQUERADE,ipt_REDIRECT,ipt_REJECT,ipt_LOG,iptable_na +t,ip_tables sch_htb 14464 0 sch_sfq 4992 0 ppp_async 8192 0 crc_ccitt 2048 1 ppp_async ppp_synctty 6912 0 ppp_generic 21140 2 ppp_async,ppp_synctty
- Miller

Replies are listed 'Best First'.
Re^2: Formatting text, eg long lines
by nanouk (Novice) on Dec 03, 2007 at 11:15 UTC
    Works a treat! Thanks a bunch.
    Cheers
    Pascal
    P.S. : would you please comment your code so that I could learn something?