My aim: Run certain kinds of log file lines thru a perl script that will:
1) Identify each line by regex that finds pattern at start of line 2) When such a line is found, print newline first then 3) wrap any lines longer than specified number of columns. I was not able to divine from `perldoc Text::Wrap' how to really use it to do what I want. my non-working effort stripped to the bare bones: use strict; use warnings; use Text::Wrap; my $rgx = qr/@{[shift]}/; $Text::Wrap::columns = 68; my @text; while (<>) { if (/$rgx/) { print "\n"; print wrap(",", @text); } } It wasn't at all clear from perldoc Text::Wrap how @text is supposed to be populated. Running the script above on the loglines included below: script '^Aug ' file-with-logs The script above prints only a bunch of blank lines. On the data below: ------- ------- ---=--- ------- ------- Aug 13 19:59:10 u0 postfix/pickup[7901]: 1993C180CB9: uid=1000 from=<reader> Aug 13 19:59:10 u0 postfix/cleanup[7920]: 1993C180CB9: message-id=<20170813235910.1993C180CB9@u1> Aug 13 19:59:10 u0 postfix/qmgr[7902]: 1993C180CB9: from=<rea...@u0.local.lan>, size=1377, nrcpt=1 (queue active) Aug 13 19:59:10 u0 postfix/smtp[7922]: 1993C180CB9: to=<hp...@fastmail.fm>, relay=smtp.fastmail.com[66.111.4.139]:587, delay=0.7, delays=0.15/0.08/0.35/0.11, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 7240B7F986) Aug 13 19:59:10 u0 postfix/cleanup[7920]: B5619180CBB: message-id=<20170813235910.B5619180CBB@u1> Aug 13 19:59:11 u0 spamd[831]: spamd: result: . 0 - DKIM_ADSP_NXDOMAIN,NO_RELAYS scantime=0.3,size=2008,user=reader,uid=1000,required_score=5.0,rhost=localhost,raddr=::1,rport=56648,mid=<20170813235910.B5619180CBB@u1>,autolearn=no autolearn_force=no -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/