LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-02-2004, 03:27 AM   #1
pantera
Member
 
Registered: May 2004
Posts: 80

Rep: Reputation: 15
perl printing


how to match a field in a line and print the next line??
 
Old 06-02-2004, 02:07 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
What about something like:
Code:
# Loop through the lines
foreach $line (@lines){
 # If the last line matched then print it
 if($next eq "print"){
  $next="skip";
  print $line;
 }
 # If the line contains "somestring" then keep track in a variable
 if($line=~/somestring/){$next="print"}
}

Last edited by david_ross; 06-02-2004 at 02:09 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl - printing progress on same line. Technoslave Programming 7 09-03-2011 09:20 PM
printing Spanish accent characters in Perl/tk entry widget puedo Programming 1 02-19-2005 01:16 PM
Perl - printing features satimis Programming 6 11-14-2004 11:45 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM


All times are GMT -5. The time now is 12:35 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration