when I run:
perl -e '$x="abc\nxyz\n123"; $x =~ s/\n.*/... multiline.../; printf("str %s\n", $x);'
I expect result to be:
str abc... multiline...
instead I get
str abc... multiline...
123
Where am I going wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
/smodifier tells Perl to treat the matched string as single-line, which causes.to match newlines. Ordinarily it doesn’t, resulting in your observed behavior.