You are changing a specific letter in one case, but it won't work in other ones.
A more general solution might be to create a global "contains"
<%contains (<%var%>, <%string%>)%>
This returns a tag CONTAINS which is True or False depending on the compare.
my ($var, $str) = @_;
m|$var|$str|gi && return ( {CONTAINS=>'True'} );
return ( {CONTAINS=>'False'} );
}
Not sure if this works, haven't tested it, but the idea is there.
Then in your templates, you'd use
<%if CONTAINS eq 'True'%> do something <%endif%>
The value of CONTAINS will always be the most recent test, so you can reuse this. You could also pass in the return variable, so you could use multiple tests, keeping the value of each for subsequent use.
There are still some bugs using the value of a function in a test, so you need to use this long form to get the value of the subroutine into a variable.
PUGDOG� Enterprises, Inc.
The best way to contact me is to NOT use Email.
Please leave a PM here.
A more general solution might be to create a global "contains"
<%contains (<%var%>, <%string%>)%>
This returns a tag CONTAINS which is True or False depending on the compare.
Code:
sub { my ($var, $str) = @_;
m|$var|$str|gi && return ( {CONTAINS=>'True'} );
return ( {CONTAINS=>'False'} );
}
Not sure if this works, haven't tested it, but the idea is there.
Then in your templates, you'd use
<%if CONTAINS eq 'True'%> do something <%endif%>
The value of CONTAINS will always be the most recent test, so you can reuse this. You could also pass in the return variable, so you could use multiple tests, keeping the value of each for subsequent use.
There are still some bugs using the value of a function in a test, so you need to use this long form to get the value of the subroutine into a variable.
PUGDOG� Enterprises, Inc.
The best way to contact me is to NOT use Email.
Please leave a PM here.