>>>>> "AA" == Alex Aminoff <a...@basespace.net> writes:

  AA> I hope that is clear.

  AA> I misunderstood what someone was suggesting, but basically

  AA>  s/\$(\w+)/$object->$1()/sgex;

  AA> will work, except that I did not trust my own regexp. Better:

that is just a basic templater as i said before. now the question comes
down to WHAT markup do you want to designate a method call to be made?
there is no reason to use perl's $foo style here since perl never sees
it. and $foo is hard to parse if it is next to text as in "$foobar". is
that $foo and then bar? or $foobar? perl uses braces to disambiguate
that. so why not choose a brace style to begin with? that is what
template::simple does already as do others. a pairs bracket is easy to
parse, sticks out, is hard to accidentally have in the text, etc.

  AA>  s/\$(\w+)/ $object->can($1) ? $object->$1() : '$' . $1 /sgex

why are you concerned with this? are you in charge of the input string?
if you are in charge, then why can't you just make sure your $foo tokens
are always properly matched to method names? it is your job anyway. how
often would text have $foo that isn't a method call? or use fancy paired
brackets like i keep saying since that is unlikely to be in text.

  AA> that will leave the orignal text untouched unless there is a method
  AA> available. Is there a better regexp than \$(\w+) to identify anything
  AA> that the perl parser would identify as a variable?

yes, don't use $foo for the token. see my reasons above.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to