[Petal] Modifiers and variables
Fergal Daly
fergal at esatclear.ie
Thu Aug 19 13:38:15 BST 2004
On Thu, Aug 19, 2004 at 08:26:44AM -0400, William McKee wrote:
> 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.
That's not quite what I'm talking about. It doesn't matter if the item is
found or not, this is more to do with looking for the end of the expression.
For example
parse_one_arg("this/that/theother something else")
would get as far as the space after "theother" and realise that it has
reached the end of an expression. It would return return whatever that
expression evaluates to and it would return " something else". It's not
relevant whether a value is found or not, this is about what the string
means,
F
More information about the Petal
mailing list