I understand that the following script would print out line(s) separated by ‘–‘ (2 dashes), but how can I use it when there are many ‘-‘ (dashes)?
{
local $/ = "--\n";
while (<>) {
chomp;
print;
}
}
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.
You’ll have to roll your own data stream parser.
$/isn’t up to the task:But a line that ends with three dashes and a newline is also a line that ends with two dashes and a newline. Wouldn’t it be sufficient just to swap out the
chompcommand?or
for the case where the last record in the data doesn’t end with the record separator string.