[SOLVED] Perl: Multiline Not Working Though Using Single Line Mode
by blueray from LinuxQuestions.org on (#52A53)
The following code works:
Code:$ echo "Name:James Herriot Bladibla James Herriot:9" | perl -ne '/Name:(\w*\s\w*).*\1:(\d)/ and print $2'But when I insert newline in the input, it does not work anymore (I tried using single line mode when using \n).
The following code does not work:
Code:$ printf "Name:James Herriot\nBladibla\nJames Herriot:9" | perl -ne '/Name:(\w*\s\w*).*\1:(\d)/s and print $2'What might be the issue here?


Code:$ echo "Name:James Herriot Bladibla James Herriot:9" | perl -ne '/Name:(\w*\s\w*).*\1:(\d)/ and print $2'But when I insert newline in the input, it does not work anymore (I tried using single line mode when using \n).
The following code does not work:
Code:$ printf "Name:James Herriot\nBladibla\nJames Herriot:9" | perl -ne '/Name:(\w*\s\w*).*\1:(\d)/s and print $2'What might be the issue here?