On 6/24/07 10:42 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> You don't need to repeat the pattern by hand - the /g will do that for
> you.
>
Thanks to everyone for the replies.
I expected what you pointed out above, that /\b(w+)\s+(\w+)\s+/gs would
match every instance of the pattern. Instead I got wildly results, with
random letters in some variables and the values I wanted in a different
offset every time. I cannot explain that, but the pattern works with the
left hand values written as literals (/\b(word)\s+(.*)\s+/)
> Are newlines significant? Or can just treat it as a list of
> alternating keys and values delimited by whitespace?
>
This can be treated as key/values delimited by whitespace.
I wonder if the unexpected results could be related to tabs or something
else besides \n? How do I see what's used for white space? Shouldn't \s
match any whitespace character?
> Probably a list of hashes would be the most natural.
>
> my @LoH = map { { split } } $file_contents =~ /\{(.*?)\}/gs;
Thanks. That's cool. Since this is the beginner's list, I'll just dive in
and ask a(nother) dumb question. I'm not sure I understand the double curly
braces around split. Would you mind showing me that in a less terse form?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/