http://qs321.pair.com?node_id=525975


in reply to Pattern problem

Maybe something as simple as this?

#!/usr/local/bin/perl use strict; while (<DATA>) { if (/Host System [^#]/) { print "$_"; } } __DATA__ Status Host Pluto up Host System Pluto 10.1.4.11 Host System Mars IP 10.1.3.10 Status Host Jupiter down Host System #neptune IP 10.10.10.10 Disk load Mars imminent Host System Venus IP 12.1.2.13.14

No good deed goes unpunished. -- (attributed to) Oscar Wilde

Replies are listed 'Best First'.
Re^2: Pattern problem
by mk. (Friar) on Jan 27, 2006 at 14:33 UTC
    or simply
    perl -ne 'print if /Host System [^#]/;' records.txt


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    grrr.... argh!
      perl -pe 's/(Host System [^#].+)|.+/$1/gs' records.txt
      =****

      Mago
      mago@rio.pm.org