On Fri, Oct 01, 2004 at 06:14:52AM -0700, $Bill Luebkert wrote:
> > my ($blob) =
> > "<record><tag1>aValue</tag1><tag2>aa:bb:cc:last</tag2></record>";
> $blob =~ /tag1>([^<]+)<\/tag1>/;
> print $1, "\n";

If you have to do it this way (rather than a real XML parser/scanner),
I would suggest using list assign, including the opening tag '<',
blocking '>' from being part of $aValue, checking that the pattern
does indeed match, and perhaps using a different match pattern
delimiter than '/':

  my($aValue) = $blob =~ m[<tag1>([^<>]+)</tag1>]
      or die "Blob doesn't include <tag1>!\n";

Mostly, it just means your code is clearer to a later reader, and a little
more robust...

Just a suggestion,
mark

-- 
[EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL PROTECTED] __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to