Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by moritz (Cardinal)
on Oct 13, 2013 at 11:09 UTC ( #1058059=note: print w/ replies, xml ) Need Help??


in reply to How to extract certain range of text and write into another file?

Your most obvious problem is that there is no occurrence of Corry in the test data, only corry. And no, the two are not the same.

Another problem is that you use $1, but the regex before it doesn't use a capturing group that could fill $1.

A third problem is that the iteration variable is $word, but the regexes match against $_, thus have no chance to succeed. I'm pretty sure you get an uninitialized... warning from that. Didn't you? Or did you just ignore it? (hint: never ignore the warning).


Comment on Re: How to extract certain range of text and display it?
Select or Download Code
Re^2: How to extract certain range of text and display it?
by annel (Novice) on Oct 14, 2013 at 01:30 UTC
    Hi, the problems you have mentioned are totally correct. I have correct the occurrence of  corry and get rid of $word. I can't figure out what variable should I match the section text.

      I can't figure out what variable should I match the section text.

      post the new code

        Here is the code I updated. Please check it. Thanks.
        use warnings; use strict; my $test; my @words; open(INFO,"<","testing.pl")||die"Can't open file:$!\n"; chomp (@words=<INFO>); close(INFO); foreach @words){ if(/^\$ NAME : corry/ .. /\.EON/){ $test=$1; print $test; } }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2014-09-17 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (92 votes), past polls