943,919 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 473
  • Perl RSS
Aug 3rd, 2009
0

seeking help

Expand Post »
use warnings;
use strict;

open (TEXT_FILE,'C:\Documents and Settings\rnjenga\sawa3.txt');


my ($line, $nextline);
while ($line = <TEXT_FILE>) {


if ($line =~ /FT\s*\Wnote.+\w+:/){
$nextline = <TEXT_FILE> ;
print ("$line $nextline \n");
}

if ($line =~ /FT\s*\Wnote.+none/){
$nextline = <TEXT_FILE> ;
print ("$line $nextline \n");
}

}
close (TEXT_FILE);

I have written the above code to be able to pull the following results out of the text file.

FT /note="go_function: nutrient reservoir activity [goid
FT 0045735]"


FT /note="none"

Now I need you help to be able to write a code that will copy the BOLD string onto the second one.
I have tried too see if I can be able to skip it during reading the file but to no avail.
Kindly assist.

Thanks and God Bless.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rayken1 is offline Offline
8 posts
since Jun 2009
Aug 3rd, 2009
0

Re: seeking help

Have you tried loading the entire file into a variable for searching? You can do this by:

Perl Syntax (Toggle Plain Text)
  1. undef($/);
  2. open(FILE,"<file.txt");
  3. while(<FILE>){
  4. $allfile=$_;
  5. }

Then run a multi-line regex on the vairable.
Reputation Points: 26
Solved Threads: 38
Posting Whiz in Training
mitchems is offline Offline
293 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: raw data: help
Next Thread in Perl Forum Timeline: Perl script syntax errors





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC