Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: How to extract certain range of text and display it?

by annel (Novice)
on Oct 15, 2013 at 05:34 UTC ( #1058237=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to extract certain range of text and display it?
in thread How to extract certain range of text and write into another file?

Thanks for your response. I have updated my code and question. Can you give me some idea where to define $/?
  • Comment on Re^4: How to extract certain range of text and display it?

Replies are listed 'Best First'.
Re^5: How to extract certain range of text and display it?
by soonix (Monsignor) on Oct 15, 2013 at 08:44 UTC
    For example, I need to extract the $ NAME: sandy until $$.TO and then join with the contents inside $NAME: patrick which is start from G1 until $$SRU.
    Your sample data seems to indicate that the data for each name starts with "$ NAME" and ends with a line ".EON", which is the base of our suggestions until now. The quoted sentence seems to indicate something different. So you should clarify:
    • how do you recognize which line belongs to which name (via $ NAME and .EON, or different)?
    • how do you determine which part of those lines for a particular name you are interested in?
    • [Update: additional question] do you need to preserve the order of these entries/lines?
Re^5: How to extract certain range of text and display it?
by Anonymous Monk on Oct 15, 2013 at 06:48 UTC
    Um, why not simply "copy/paste" what others have posted? Up above?
      Do you mean this one?
      use Modern::Perl; { local $/ = ".EON\n\n"; while ( my $record = <DATA> ) { say "I found: $record"; # ... now do something with $record ... } }
      use Modern::Perl prompts to give error.

        "use Modern::Perl prompts to give error."

        Something like this:

        Can't locate Modern/Perl.pm ...

        If so, install the module:

        cpan Modern::Perl

        If this isn't the problem you're going to have to be more specific. Please read and understand How do I post a question effectively? to find out how to help us help you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058237]
help
Chatterbox?
[marto]: the back pain is still there, it's been a rough week, trying to do building work with a bad back
[Corion]: marto: Ow! That doesn't sound good :-/ The work won't help your back...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2017-09-21 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (248 votes). Check out past polls.

    Notices?