Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Help required in writing the perl script

Expand Messages
  • Edward Willekens
    $open=0; if (open(FD,
    Message 1 of 3 , Apr 7 12:52 PM
    • 0 Attachment
      $open=0;
      if (open(FD,"<f1.txt")){
       while (<FD>) {
        if (/open/) {
         $open=1;
        }
        elsif (($open)&&(/null/)) {
         $open=0;
         next;
        }
        print $_."\n";
       }
       close(FD);
      }
        

      --- On Wed, 4/7/10, bpuri_12 <bpuri_12@...> wrote:

      From: bpuri_12 <bpuri_12@...>
      Subject: [PBML] Help required in writing the perl script
      To: perl-beginner@yahoogroups.com
      Date: Wednesday, April 7, 2010, 4:29 AM







       









      Hi,



      I am very new to Perl.



      Could someone please help me in writing the Following.



      I want to delete a line containing pattern from the file if it appears after another specific pattern in the previous line



      e.g in the below file(lines are numbered for reference), I want to delete lines containing "null" if it appears after open.. so I want to delete line nos 4 and 10



      f1.txt

      1.abc

      2.test

      3.open

      4.xyz-null

      5.test

      6.null

      7.

      8.open

      9.

      10.null

      11.test



      Thanks in advance

























      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.