Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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).

Replies are listed 'Best First'.
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?
choroba waits
[thepkd]: $aohoaoh ->{'foo'} has to be dereferenced to access its contents right?
[thepkd]: sorry. i mean $aohoaoh[0]
[GotToBTru]: $aohoaoh is an array reference tho
[thepkd]: some guy was suggesting $aohoaoh[0]->{'foo '}[0]->{}. This wouldnt work.
[GotToBTru]: you're mixing notation there I think

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2016-12-06 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.