The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search for a string -perl meghana Shell Programming and Scripting 11 02-12-2008 09:44 PM
Perl: Search for string on line then compare numbers! Crypto Shell Programming and Scripting 2 01-22-2008 01:50 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 10:24 AM
Search and Parse string from inside a File SSims UNIX for Dummies Questions & Answers 2 11-08-2007 03:50 PM
Search string in array (perl) man Shell Programming and Scripting 6 07-24-2007 12:14 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-06-2006
pondlife pondlife is offline
Registered User
  
 

Join Date: May 2004
Location: UK
Posts: 85
Perl: Search for string then parse next line

Hi All,

I have a file that I need to be able to find a pattern match on one line then parse data on the next or subsequent lines - I will know which line needs to be parsed beforehand.

This is what I currently have:


Code:
while (<COMMAND_OUT>) {

   if ($_ =~ m/TEST/) {

      $enabled_yn{IMSI} = substr($_,-17,15) ;
   }

   if ($_ =~ m/BAOC/) {

      $enabled_yn{BAOC} = substr($_,-3,2) ;

   }

   if ($_ =~ m/BOIC/) {

      $enabled_yn{BOIC} = substr($_,-3,2) ;

   }
}

This works find when the string that I need to parse is on the same line but wont work when the string that I need to capture is on the next line.

I think the answer lies in manipulating $. but I'm unsure how to do this...

Many thanks,

pondlife.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0