in reply to How to print the lines immediately above and below a matching line?

if ($this_line =~ /<DATA>/) {
Are you trying to read from the special DATA handle, or are you trying to match the exact string <DATA>? re indicates you are doing the latter:
perl -Mre=debug mycode.pl Compiling REx "<DATA>" Final program: 1: EXACT <<DATA>> (4) 4: END (0) anchored "<DATA>" at 0 (checking anchored isall) minlen 6 Error opening file - No such file or directory Freeing REx: "<DATA>"

Replies are listed 'Best First'.
Re^2: How to print the lines immediately above and below a matching line?
by Bio90 (Initiate) on Nov 25, 2012 at 13:36 UTC
    Hi, thanks for your reply.

    I am trying to match from the DATA handle.

      Then you need to change your code. Something like:
      my $data = <DATA>; chomp $data; if ($this_line =~ /\Q$data/)
        I have tried that but it has returned a "Use of uninitialised value $data". I do not understand - surely $data is initialised by my $data = <DATA>;?
      Maybe you should read a line from that handle instead ... don't skip the basics, read perlintro
        I'm sorry, I am a Biology student and I have merely had perl suggested to me as a means to an end in order to get my data into a usable format.