Hoot has asked for the wisdom of the Perl Monks concerning the following question:
Hi
Say I have a poem called:
A Beautiful Poem
Mary had a little lamb, little lamb, little lamb
Mary had a DOG but everywhere that mary went the lamb was
sure to go even though it did not like the dog very much.
Is it possible to have DOG as the pattern to match and store everything before it in a variable and everything after it in another variable?
I have tried $` and $& and $' but can't get my head around the new lines etc.
I want to be able to capture the title of the poem and the poem itself and DOG.
Can somebody help me please?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Storing Lines before and After pattern
by Zaxo (Archbishop) on Jan 27, 2004 at 01:05 UTC | |
Re: Storing Lines before and After pattern
by allolex (Curate) on Jan 27, 2004 at 00:58 UTC | |
by Coruscate (Sexton) on Jan 27, 2004 at 05:26 UTC | |
Re: Storing Lines before and After pattern
by jweed (Chaplain) on Jan 27, 2004 at 01:00 UTC | |
by ysth (Canon) on Jan 27, 2004 at 01:09 UTC | |
Re: Storing Lines before and After pattern
by Abigail-II (Bishop) on Jan 27, 2004 at 01:00 UTC |
Back to
Seekers of Perl Wisdom