in reply to Unable to match newline

Your oneliner is reading one line, but your match target spreads across multiple lines. You could instead slurp the whole file into memory, or maybe just read the first two kilobyte of any file to match against it.

Replies are listed 'Best First'.
Re^2: Unable to match newline
by robinson (Novice) on Nov 17, 2015 at 20:09 UTC

    Thanks for your reply. How can I do this in one line? (I mean without having to create a file with the code in it).

    I apologize if this seems like a very basic question but my knowledge of Perl is very low.

      perl -0777 -e 'somecode' will slurp the whole file when you read it with a diamond operator. See perlrun - but single-liner-ing your code isn't always a good thing for readability and maintainability