|
|
| Welcome to the Monastery | |
| PerlMonks |
Split and empty stringsby andye (Curate) |
| on Apr 10, 2001 at 15:14 UTC ( [id://71361]=perlquestion: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.andye has asked for the wisdom of the Perl Monks concerning the following question:
Hi folks,
Quite a simple one, but it's puzzling me. I'm trying to match each line of a string, including empty lines. I've found that foreach (/(.*)/gm) does the job - because if it sees two newlines in a row, then dot star matches (0 copies of any-character-but-newline) and it returns an empty string. And that's fine. But then I thought to myself, hang on, I should be using split here, so I changed it to foreach (split /\n/) ...and it doesn't match empty lines. I've looked in the Cameliad, but either it doesn't explain or (more likely) I'm not understanding correctly. Could someone explain? Cheers, andy.
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||||||||