Extract data and put in this format

How do i extract the data that are between the plus'+' sign from a file and write it into another file in this output??
Example  !+9.975869E+02!+9.950317E+02!+1.000017E+03!+9.976589E+02!+9.950910E+02
I only want 9.975869E+02
Please help!!!
Thanks a lot

Actual output:

1  1  1.003E+03   3.980E-08   4.994E-04   2.496E+00   3.961E-08   4.966E-04
  1  7  9.943E+02   3.994E-08   4.968E-04   2.496E+00   3.948E-08   4.974E-04
  1  9  1.000E+03   3.949E-08   4.979E-04   2.498E+00   3.985E-08   4.985E-04
  1  3  1.001E+03   3.949E-08   4.965E-04   2.480E+00   3.968E-08   4.962E-04
  1  5  9.952E+02   3.963E-08   4.999E-04   2.491E+00   3.986E-08   4.963E-04



Source data from a file:

XB8B_Amodule_R1K_R_Rmeas!1K ohm resister!R!ohm!+1.002825E+03!+9.942619E+02!+9.999966E+02!+1.001386E+03!+9.951618E+02
XB8B_Amodule_MFA1_FETCHK_Idoff!MOSFET!R!A!+3.979751E-08!+3.994000E-08!+3.949102E-08!+3.948680E-08!+3.963226E-08
XB8B_Amodule_MFA1_FETCHK_Idon!MOSFET!R!A!+4.994273E-04!+4.967769E-04!+4.978503E-04!+4.964730E-04!+4.999332E-04
XB8B_Amodule_MFA1_VT_Vt!!R!V!+2.495615E+00!+2.495548E+00!+2.498353E+00!+2.479673E+00!+2.490514E+00
kopibeanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kopibeanAuthor Commented:
Edited text of question.
0
noelhCommented:
Open the file then replace everything that is not in between the !+ signs.

example

#open the file
open FILE, "path_to_file";
#put all the data into @DATA
@DATA = <FILE>;

close FILE;

#open a new file then prepare to write #the good data back to the new file
open NEWFILE, "path_to_new_file";

#take each line one at a time
foreach $line(@DATA){

#remove everything in the current line #that isn't between !+ signs
$gooddata =~ s/!+.*^!+//g;

#write the new data back to the new file

print NEWFILE $gooddata;

# keep working till all the lines are  # done
}
#close the new file
close file;
#exit the program
exit;


0
kopibeanAuthor Commented:
I try it out but it can't seem to work
Please provide more clearer codes
Thanks
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

MindoCommented:
The text of the script is:

========================================
#!usr/local/bin/perl -w

while(<>)
{
  while(/!\+([0-9E.+\-]+)/g)
  {
        print "$1\n";
  }
}========================================

Given the following data file:

========================================
!+9.975869E+02!+9.950317E+02!+1.000017E+03!+9.976589E+02!+9.950910E+02
!+9.975869E+02!+9.950317E+02!+1.000017E+03!+9.976589E+02!+9.950910E+02
!+9.975869E+02!+9.950317E+02!+1.000017E+03!+9.976589E+02!+9.950910E+02
========================================

The command is:

script.pl < data.txt > newfile.txt

The result is:
========================================
9.975869E+02
9.950317E+02
1.000017E+03
9.976589E+02
9.950910E+02
9.975869E+02
9.950317E+02
1.000017E+03
9.976589E+02
9.950910E+02
9.975869E+02
9.950317E+02
1.000017E+03
9.976589E+02
9.950910E+02
========================================

Again, somebody has pasted an answer before me :-) I think my solution is shorter, eh? :-?

Cheers :-)
0
kopibeanAuthor Commented:
Can someone please specify clearly the codes for the whole actual output
as how it is going to be printed out to another file in the output that I have stated
Thank you!!
Need ur help urgently.
0
MindoCommented:
Here's the output you want. I think you should arrange your output the way you want to. Add new line characters or spaces yourself.
=======================================
#!usr/local/bin/perl -w

while(<>)
{
  while(/!\+([0-9E.+\-]+)/g)
  {
        print "$1 ";
  }
  print "\n";
}
=======================================

Cheers
0
kopibeanAuthor Commented:
For the above codes by Mindo, what if i want to print it to a file??
and using it in format,is it able to do it
0
MindoCommented:
Here's the code to do this to file:
=======================================
#!usr/local/bin/perl -w

open(F, "> file.txt");

while(<>)
{
  while(/!\+([0-9E.+\-]+)/g)
  {
        print F "$1 ";
  }
  print F "\n";
}

close(F);    
=======================================

It's simple, just open, print and close the file.

Read about the Perl I/O in it's documentation :-)
0
kopibeanAuthor Commented:
hi Mindo
I like to ask u some more questions regarding about my problem
cos is quite a huge problem
can give me ur email address?
thanks a lot for ur help.

THere is another thing Using format, will the above code do it?
0
MindoCommented:
Hey, state your problem as a new question, give points and we go :-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.