in reply to Re^2: Perl reading in a file and getting a string in between two strings on different lines
in thread Perl reading in a file and getting a string in between two strings on different lines

That didn't work the output i got was just the whole file, i even tried to put an 's' at the end of it for many lines but that didn't work either.

  • Comment on Re^3: Perl reading in a file and getting a string in between two strings on different lines

Replies are listed 'Best First'.
Re^4: Perl reading in a file and getting a string in between two strings on different lines
by LanX (Saint) on Apr 17, 2017 at 21:56 UTC
    Show input that doesn't work! See SSCCE

    That's a classic, most likely you are doing it wrong.

    The only possibility top make it foolproof is to quote regex metacharacters and to anchor the line's start with ^

    print if /^\Q$beginString/ .. /^\Q$endString/;

    See quotemeta

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!