<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PERL - pattern match in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944015#M97598</link>
    <description>&lt;!--!*#--&gt;Hi Pat:&lt;BR /&gt;&lt;BR /&gt;OK, this script meets your requirement.  Once a pattern is found, the remainder of a line is stored and every line in the file thereafter.  You can do what you wish with the array --- I printed what I stored (buffered) to show the technique.&lt;BR /&gt;&lt;BR /&gt;# cat ./buffer&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pattern = shift;&lt;BR /&gt;my $ok;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    if (/($pattern)(.*)/) {&lt;BR /&gt;        push( @lines, $2 );&lt;BR /&gt;        $ok++;&lt;BR /&gt;    }&lt;BR /&gt;    push( @lines, $_ ) if $ok;&lt;BR /&gt;}&lt;BR /&gt;print "$_\n" for (@lines)&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./buffer local /etc/hosts&lt;BR /&gt;&lt;BR /&gt;...that is, pass the pattern to match followed by the file to be processed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 13 Feb 2007 17:58:15 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2007-02-13T17:58:15Z</dc:date>
    <item>
      <title>PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944013#M97596</link>
      <description>I am writing a PERL script that would search for a pattern in a file. Once the pattern is found, the script should store the portion of the file from the pattern till the end of the file in a buffer for further processing.&lt;BR /&gt;&lt;BR /&gt;I am somehow not able to get the logic.&lt;BR /&gt;&lt;BR /&gt;Can anyone please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat</description>
      <pubDate>Tue, 13 Feb 2007 16:57:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944013#M97596</guid>
      <dc:creator>Pat Tom</dc:creator>
      <dc:date>2007-02-13T16:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944014#M97597</link>
      <description>Hi Pat:&lt;BR /&gt;&lt;BR /&gt;OK, this script meets your requirement.  Once a pattern is found, the remainder of a line is stored and every line in the file thereafter.  You can do what you wish with the array --- I printed what I stored (buffered) to show the technique.&lt;BR /&gt;&lt;BR /&gt;# cat ./buffer&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pattern = shift;&lt;BR /&gt;my $ok;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    if (/($pattern)(.*)/) {&lt;BR /&gt;        push( @lines, $2 );&lt;BR /&gt;        $ok++;&lt;BR /&gt;    }&lt;BR /&gt;    push( @lines, $_ ) if $ok;&lt;BR /&gt;}&lt;BR /&gt;print "$_\n" for (@lines)&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./buffer local /etc/hosts&lt;BR /&gt;&lt;BR /&gt;...that is, pass the pattern to match followed by the file to be processed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Feb 2007 17:58:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944014#M97597</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-13T17:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944015#M97598</link>
      <description>&lt;!--!*#--&gt;Hi Pat:&lt;BR /&gt;&lt;BR /&gt;OK, this script meets your requirement.  Once a pattern is found, the remainder of a line is stored and every line in the file thereafter.  You can do what you wish with the array --- I printed what I stored (buffered) to show the technique.&lt;BR /&gt;&lt;BR /&gt;# cat ./buffer&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pattern = shift;&lt;BR /&gt;my $ok;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    if (/($pattern)(.*)/) {&lt;BR /&gt;        push( @lines, $2 );&lt;BR /&gt;        $ok++;&lt;BR /&gt;    }&lt;BR /&gt;    push( @lines, $_ ) if $ok;&lt;BR /&gt;}&lt;BR /&gt;print "$_\n" for (@lines)&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./buffer local /etc/hosts&lt;BR /&gt;&lt;BR /&gt;...that is, pass the pattern to match followed by the file to be processed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Feb 2007 17:58:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944015#M97598</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-13T17:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944016#M97599</link>
      <description>Pat, &lt;BR /&gt;&lt;BR /&gt;JRF has the 'de luxe' solution.&lt;BR /&gt;If you study it, you'll see it raises (and answer) some questions:&lt;BR /&gt;&lt;BR /&gt;'from the pattern' is that to be taken literally? That is, should it included the pattern itself, or perhaps even the whole 'line' which contained the pattern?&lt;BR /&gt;&lt;BR /&gt;'till the end': What to do with new-lines?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;probably not what you need, but here is a one line for the simplest interpretation of the request...&lt;BR /&gt;&lt;BR /&gt;perl -ne '$go++ if /pattern/; print if $go' &lt;INPUT /&gt; &amp;gt; &lt;OUTPUT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;/OUTPUT&gt;</description>
      <pubDate>Tue, 13 Feb 2007 18:11:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944016#M97599</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-02-13T18:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944017#M97600</link>
      <description>&lt;!--!*#--&gt;Hi (again) Pat:&lt;BR /&gt;&lt;BR /&gt;Sorry for the double post.  The Forum returned an error in posting the first time --- I should know better.&lt;BR /&gt;&lt;BR /&gt;There is a dumb correction, anyway I need to make!  The original solution dropped a 'next' and treated multiple instances of the pattern downstream from the first occurance as reason to chop the beginning of the line again.  That's probably not desirable.  Hence, use this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pattern = shift;&lt;BR /&gt;my $ok;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    if ( /($pattern)(.*)/ &amp;amp;&amp;amp; ! $ok ) {&lt;BR /&gt;        push( @lines, $2 );&lt;BR /&gt;        $ok++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    push( @lines, $_ ) if $ok;&lt;BR /&gt;}&lt;BR /&gt;print "$_\n" for (@lines);&lt;BR /&gt;&lt;BR /&gt;Note, however, that you will *miss* the line which *ends* with the pattern sought.  According to your specifications, you only want "...from the pattern until the end...".  Perhaps you can clarify what behavior you want.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 14 Feb 2007 08:19:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944017#M97600</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-14T08:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944018#M97601</link>
      <description># perl -ne'1../pattern/ or print' file &amp;gt; part&lt;BR /&gt;&lt;BR /&gt;Explain what is wrong with that?&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 14 Feb 2007 08:23:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944018#M97601</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-02-14T08:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: PERL - pattern match</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944019#M97602</link>
      <description>Hi Merijn,&lt;BR /&gt;&lt;BR /&gt;your oneliner will not output the line with the first match :-)&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Feb 2007 03:33:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-match/m-p/3944019#M97602</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-02-15T03:33:09Z</dc:date>
    </item>
  </channel>
</rss>

