Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: regex/extracting whole lines

by strfry() (Monk)
on Oct 19, 2001 at 17:48 UTC ( [id://119983]=note: print w/replies, xml ) Need Help??


in reply to regex/extracting whole lines

here's my version of it:
#!/usr/bin/perl use warnings; use strict; my ($line,$i,$n,$emailtext); while( $line=<DATA> ) { if( $line =~ m/^\*\*$/) { $emailtext .= <DATA> if(*DATA); next if ( $line =~ m/^\*\*$/ ); } } print "$emailtext\n"; # you could start your print MAIL # stuff here. __DATA__ ** She turned me into a newt! ** One day, a shell shall emerge from the masses, written in Perl, and it will be Good. ** A newt?! ** The people will rejoice, and it shall be dubbed 'SuperShell'. ** I got better. **
i wasn't entirely certain as to what you were trying to accomplish, though, so this might not be very useful. ):

strfry()

Replies are listed 'Best First'.
Re: Re: regex/extracting whole lines
by kelleher (Initiate) on Oct 19, 2001 at 18:17 UTC
    Thanks to all of you and apologies for not being clearer. I have a script that makes and builds the distribution for various apps and outputs results as .txt files. What I really need is to extract various results/summaries etc from the output files, strip of characters such as '*' and '-' and, as I'm using a cmd line mailer, set the results/summaries as variables. Again, sorry for not being clearer
      hmm can you maybe paste an example of the output file (pre-regex), and if possible, show us how you want the output to appear (post-regex)?
      eg: if your file looks like so -
      ** - blah blah blah - **
      and you want it to look like this:
      blah blah blah
      then it'd be a very simple fix.

      strfry()
        Does'nt quite fit, each line starts with a double *. This is just a fraction of one of the outputs, what would be good is if I could take the 'Datasource' line and the Summary line and strip everything between. ************************************************************************ ** Datasource: EJB ** ************************************************************************ *********************************************************************** ************************************************************************ ** ** ** Exception: ** ** ** ** test.demo.oms.control.testOrganization ** ** test.demo.oms.equity.testEquitySecurityGroup ** ** test.demo.oms.lifecycle.testLifeCycleEngine ** ** test.demo.oms.lifecycle.testLifeCycleGraph ** ** test.demo.oms.ome.testOrderMatch ** ** test.demo.oms.ome.testOrderMatchingEngine ** ** test.demo.oms.trade.testOrder ** ** test.net.appl.jrisk.empiricalrisk.measure.irdelta.testIRDeltaMeasure ** test.net.appl.jrisk.equity.ejb.testEquitySecurityBeanBF ** ** test.net.appl.jrisk.interestrate.tc.index.testCaptureDefDiscreteCMSIndex ** test.net.appl.jrisk.interestrate.tc.index.testCaptureDefDiscreteMMIndex ** test.net.appl.jrisk.interestrate.tc.testCaptureDefLoanDeposit ** ** test.net.appl.jrisk.mktdata.curve.curve.testCaptureDefZeroCurve* ** test.net.appl.jrisk.mktdata.tc.testMarketDataOwnerQAS ** ** test.net.appl.jrisk.reference.testClassificationPersistence ** ** test.net.appl.jrisk.thinclient.ejb.testServletBridge ** ** ** ************************************************************************ ************************************************************************ ** ** ** Summary: 329 passed, 23 failed, 16 exceptions, 0 warning ** ** ** ************************************************************************

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://119983]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found