Re: Modifiers and variables
William McKee <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.petal |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Aug 19, 2004 at 12:18:50PM +0100, Fergal Daly wrote: > So what you really need is a parse_one_arg which tries to use the start of > the string as an expression, consuming as much as possible but also gives > you back what it couldn't use. Then you could easily do That's an interesting idea. Right now the dev release of Petal::Utils::Base contains a fetch_arg() subroutine which I've posted to the list which contains the following rules: if string contains single quote, remove quotes and return if string == number and/or contains a decimal point, return it else lookup in hash and return Your rule to return just the string if item is not found in the hash may be a useful addition and wouldn't be hard to implement. It would be made even easier if Petal::Hash::fetch returned the original arg if it did not exist in the hash. However, this may not sit well with the current implementation of fetch and could lead to unexpected results in the case of a typo in the template or by the programmer filling out the hash being passed to process(). Of course, I don't think Petal complains now if an item is not found. But some existing tests (both conditional tests and test scripts) may fail if fetch starting returning values when none were expecting. So far, my needs as a modifier author have been very simple. The simple syntax rules above are sufficient. I suspect that they probably miss several edge cases that Jean-Michel and you can dream up, though. I'll have to leave those details to the brains of this operation <g>. Cheers, William -- Knowmad Services Inc. http://www.knowmad.com