in reply to REGEX question

This sounds suspiciously like homework only because you say that you have not been able to try it. Maybe you should have tried it before submitting it.

That being said, I will give you the benefit of the doubt. My guess is that it will not work because it should be lc($string) not lc $string or lc_$string.

Also, for readability I would do:

for ( keys %input ) { my $string = $_ . $input->param('wrapper'); my $lcstring = $input->param('wrapper') . lc($string); my $ucstring = $input->param('wrapper') . uc($string); $report =~ s/$input->param('wrapper')$string/$input->param($_)/g; $report =~ s/$input->param('wrapper')$lcstring/$input->param($_)/g +; $report =~ s/$input->param('wrapper')$ucstring/$input->param($_)/g +; }
At least it is a little clearer.

What is not clear, is why you want to do this. It looks very strange.

NOTE: This is untested, but I think it should work.


I admit it, I am Paco.

Replies are listed 'Best First'.
Re: Re: REGEX question
by S_Shrum (Pilgrim) on Feb 06, 2002 at 05:58 UTC

    Nope...not homework.

    I'm looking to expand the functionality of a database program that I wrote and want to be able to REGEX tokens in a template and be able to allow for forced case.

    The main issue that started this was sometimes a parameter in the $input may double as a filename. Under Unix systems, case-sensitivity must match.

    Ergo: http://...?&term=Thisandthat

    ...can only be used to call a filename that matches the same case. This way, the template creator can say ahead of time, "Since I don't know how the user is inputting (in regards to case), I can force one way or another.".

    Thanx for the help (and the benefit of the doubt!).

    Sean Shrum
    sean@shrum.net