Re: How to use Text::Wrap correctly

2017-08-23 Thread Chris Fedde
I have a utility I use to wrap logging lines and make them easier to look at. It has different features than you want but down in the core might be a few clues of some use. Without options it generates output like the below: $ wrap /var/log/mail.log Aug 23 10:39:52 crf postfix/pickup[12668]:

Re: How to use Text::Wrap correctly

2017-08-22 Thread Harry Putnam
rea...@newsguy.com (Harry Putnam) writes: > So trying to simplify things I'm running the script against 3 log > lines produced by sendmail. The 3 lines below are in a file named > `mail-loglines'. Instead of simplifying I made a mess of things... I left this line at the bottom of the script: __

Re: How to use Text::Wrap correctly

2017-08-22 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: > There is an error in what I posted (sorry). The input is read into > the $line variable, but your regular expression is implicitly > testing the default variable $_. The loop should be: > > > while ( my $line = <> ) { > if ( $line =~ /$rgx/ ) { >

Re: How to use Text::Wrap correctly

2017-08-19 Thread Jim Gibson
> On Aug 18, 2017, at 6:05 AM, Harry Putnam wrote: > > jimsgib...@gmail.com (Jim Gibson) writes: >>> > > A second attempt trying to use your last example as inspiration > follows: > > ---8< snip -8< snip -- > > use strict; > use warnings; > use Text::Wrap; > >

Re: How to use Text::Wrap correctly

2017-08-18 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: >> On Aug 13, 2017, at 6:02 PM, Harry Putnam wrote: >> >> 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 ne

Re: How to use Text::Wrap correctly

2017-08-17 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: >> On Aug 13, 2017, at 6:02 PM, Harry Putnam wrote: >> >> My aim: >> [...] >> my @text; >> >> while (<>) { >> if (/$rgx/) { >> print "\n"; >> print wrap(",", @text); >> } >> } >> >> It wasn't at all clear from perldoc Text::Wrap how @text is sup

Re: How to use Text::Wrap correctly

2017-08-13 Thread Jim Gibson
> On Aug 13, 2017, at 6:02 PM, Harry Putnam wrote: > > 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 s