Ryan,
   The doc for perl regex says that if you use both 's' and 'm' togeather
then you get ^ ans $ matching next to embedded newlns *and* '.' matching
embedded newlns which is what I want.
   I need the subs placed inside my xsp file for the PerForm package.... It
calls various methods during xsp execution to handle form generation and
handle when the form is POSTed. In any case I need these methods availiable
during XSP execution not executed during XPS execurion.  (unless I am
misunderstanding the testcode snipet you supplied :-)

    -- Chris


----- Original Message ----- 
From: "Ryan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Christopher B. Liebman" <[EMAIL PROTECTED]>
Sent: Monday, June 02, 2003 11:49 AM
Subject: Re: XPathScript problem


> First of all, pick one of the 'm' or 's' modifiers in the regex since
> they are basically opposites of each other:
>
> 'm' treats the string as a multi-line and lets ^ and $ match next to
> embedded newlines.
> 's' treats the string as a single line and lets '.' match embedded
> newlines.
>
> so use one or the other - not both.
>
> also, why don't you just use the 'testcode' property, like:
>
> $t->{'issues'}{'testcode'} = sub {
> my ($node, $t) = @_;
> $t->{'pre'} = load_status($node); # handle the 'pre' inside the
> 'testcode'
> return 1;
> };
>
> sub load_status {
> my $node = shift;
> # load and return status list from DB for single-select;
> }
> instead of hacking something together to eval your text block with the
> 'sub load_status' in it?  Especially since trying to match a subroutine
> block is much more complex than your regex would pick up (what happens
> in your regex if the subroutine has any curly brackets before the end
> of the subroutine block?).
>
> Hope this helps.
>
> Ryan
>
>
> On Friday, May 30, 2003, at 07:22  PM, Christopher B. Liebman wrote:
>
> > I'm using XPathScript to create form (PerForm) elements in an XML
> > file. I
> > need interpolation turned on *and* I need to create a 'pre' like:
> >
> > $t->{'issues'}{pre} ='
> > sub load_status
> > {
> >    # load and return status list from DB for single-select
> > }
> > ';
> >
> > The problem is that this matches the regex used to interpolate...  I
> > have
> > hacked my version to bail and do *no* interpolation if the string
> > matches
> > "m/^sub\s+.*\{(.+?)\}/ms"  a bt cheesy but works for now.  I'd much
> > rather
> > see the regex matching improved to not match sub decls...  any ideas?
> > (I'm
> > not the greatest with perl regex)
> >
> >     -- CHris
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to