[mdlug] Another sed/regex question

Michael Mikowski z_mikowski at yahoo.com
Mon Sep 29 02:40:48 EDT 2014


No language is read only.  Many of the most highly trafficked sites on the web have used mod_perl for years with teams of developers.  Like anything, it can be written poorly or well.  I suggest Perl Best Practice by Damian Conway if you want to write maintainable Perl.

I've personally moved on to another supposedly "write only" language and am in high demand.  Its called "JavaScript".  Its got all sorts of warts and is not the most elegant language by any means.  But it is fast and runs on 2 billion devices.

Perl is a great sysadmin language and is a hard dependency for almost all distros.  Its much nicer and easier to maintain than JS.  It just takes discipline and effort.

On Sep 28, 2014 10:31 PM, Aaron Kulkis <akulkis00 at gmail.com> wrote:
>
> Mat Enders wrote: 
> > I use sed and awk quite a bit and that is how I would have done it.  Perl I 
> > am sure can do it but I am just starting to learn Perl. 
>
> about 15 years ago, I started teaching myself perl. 
>
> Finally decided after 2 years to stop wasting my time -- it's a "write-only" 
> language, and I have no interest in writing code which is nearly impossible 
> to maintain. 
>
> > 
> > On Fri, Sep 26, 2014 at 6:37 PM, Jeff Hanson <jhansonxi at gmail.com> wrote: 
> > 
> >> Have a input with mixed lines of data, some desirable, some not.  Valid 
> >> lines have a particular text and digit pattern which needs to be extracted 
> >> (very predictable).  If a line contains a particular number then it is 
> >> output encapsulated by one set of ASCII terminal escape codes for setting 
> >> text color.  If it has a non-matching number then it is output with a 
> >> different set of codes.  I need something like: 
> >> 
> >> program_output | sed 
> >> s/match_pattern/MATCHCODE_cleaned-up_output_RESETCODE 
> >> !NOMATCHCODE_cleaned-up_output_RESETCODE 
> >> 
> >> I'm not sure how to combine the match/no-match replacements in one 
> >> operation.  Currently I'm using: 
> >> 
> >> program_output | sed 
> >> -ne s/match_pattern/MATCHCODE_cleaned-up_output_RESETCODE/p 
> >> -ne 
> >> 
> >> /match_pattern/!{s/valid_data_pattern/NOMATCHCODE_cleaned-up_output_RESETCODE/p} 
> >> 
> >> I know this can be done in one line of awk/perl/whatever but I'm trying to 
> >> avoid additional dependencies. 
> >> _______________________________________________ 
> >> mdlug mailing list 
> >> mdlug at mdlug.org 
> >> http://mdlug.org/mailman/listinfo/mdlug 
> >> 
> > 
> > 
> > 
>
> _______________________________________________ 
> mdlug mailing list 
> mdlug at mdlug.org 
> http://mdlug.org/mailman/listinfo/mdlug 


More information about the mdlug mailing list