<?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 matching in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919099#M97060</link>
    <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Here's a simple solution:&lt;BR /&gt;&lt;BR /&gt;# cat .findpat&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pat = shift;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    shift @lines if $#lines &amp;gt;= 2;&lt;BR /&gt;    if (/$pat/) {&lt;BR /&gt;        print for @lines;&lt;BR /&gt;        print;&lt;BR /&gt;    }&lt;BR /&gt;    push( @lines, $_ );&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...Run as:&lt;BR /&gt;&lt;BR /&gt;# ./findpat pattern file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Fri, 29 Dec 2006 22:42:55 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-12-29T22:42:55Z</dc:date>
    <item>
      <title>PERL pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919097#M97058</link>
      <description>I am writing a PERL script which is required to search a pattern and display 2 lines before the first occurance of the pattern.&lt;BR /&gt;&lt;BR /&gt;Somehow I am not able to get the information using my script.&lt;BR /&gt;&lt;BR /&gt;Can anyone please let me know how to do it.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anand&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Dec 2006 21:31:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919097#M97058</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2006-12-29T21:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: PERL pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919098#M97059</link>
      <description>Please try to GOOGLE your questions before posting.&lt;BR /&gt;&lt;BR /&gt;This has been asked and answered many many times before. For example in this forum:&lt;BR /&gt;&lt;BR /&gt;Google: +perl +lines +before +site:itrc.hp.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=630972" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=630972&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Dec 2006 22:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919098#M97059</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-12-29T22:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: PERL pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919099#M97060</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Here's a simple solution:&lt;BR /&gt;&lt;BR /&gt;# cat .findpat&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $pat = shift;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    shift @lines if $#lines &amp;gt;= 2;&lt;BR /&gt;    if (/$pat/) {&lt;BR /&gt;        print for @lines;&lt;BR /&gt;        print;&lt;BR /&gt;    }&lt;BR /&gt;    push( @lines, $_ );&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...Run as:&lt;BR /&gt;&lt;BR /&gt;# ./findpat pattern file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 29 Dec 2006 22:42:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-pattern-matching/m-p/3919099#M97060</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-29T22:42:55Z</dc:date>
    </item>
  </channel>
</rss>

