Since the line between rules and subs is already blurring significantly, I want to blur it a little more. I want to write rules which can take parameters.


Consider that I am parsing HTML (a very frequent occurrence), and wish to make a Rule that matches a balanced tag from open to close. I want to use the same code many different times, but for different tags. So I really want to say something like:

   rule baltag (Rule|Str $<tag>) {
     \< $<tag> \s* $<options> := (.*?) \>
     $<body> := (.*?)
     \</ $<tag> \>
   }

I could then do:

   $buffer ~~ / <baltag title> /;

later on to match any <title> tag in my buffer.


I'm open to alternative syntaxs, this one was just there to illustrate my point.


-- Rod Adams.




Reply via email to