[ic] Problem re-using search data containing spaces

Stephen Ricketts steve at bojanglesdesign.co.uk
Mon Oct 11 11:25:54 EDT 2004


>> I included the parsed HTML to show that only '%20' (not '%2520') is in
>> 'mv_searchspec' when the form is submitted. So it is after the form has been
>> sent that it changes.
>> 
>> The code to retrieve the previous search data and create the form is quite
>> bulky, but uses the following script I found posted in the mail archives:
>> 
>> [seti lastsearch][data session last_search][/seti]
>> [perl]
>> my @sf;
>> my @se;
>> my $item;
>> my $cnt = 0;
>> my $tmpSearch = {};
>> my @searchstring = split(/\//,$Scratch->{lastsearch});
>> ## build list of sf and se
>> foreach $item (@searchstring) {
>> if ($item =~ /^sf=(.*)/) {
>> push @sf,$1;
>> }
>> elsif ($item =~ /^se=(.*)/) {
>> push @se,$1;
>> }
>> }
>> ## now build our hash of field/term pairs
>> foreach $item (@sf) {
>> $tmpSearch->{$item} = $se[$cnt];
>> $cnt++;
>> }
>> ## populate needed scratch values
>> $Scratch->{lastpublisher} = $tmpSearch->{publisher};
>> return;
>> [/perl]
>> 
>> The scratch value containing the previous publisher is then inserted into
>> the form with:
>> <input type="hidden" name="mv_searchspec" value="[scratch lastpublisher]">
>> 
>> Perhaps I need to apply a filter to the scratch value to change the '%20' to
>> a normal space? But I haven't been able to find a filter which does this,
>> and my perl knowledge is very sketchy.
>> 
>> Many thanks
> 
> Well, the above does seem like the long way around, but you can just do
> (before the return):
> 
> $Scratch->{lastpublisher} =~ s/\%20/ /g;
> 
> ...to put normal space characters back in.
> 
> - Ed

Thanks Ed,

That works perfectly. I use that perl script to extract and separate search
strings into multiple field names and their corresponding search values, the
example above has been simplified down to just one field.
However, if you are aware of a better solution I'd love to know about it. I
initially found this post
(http://www.icdevgroup.org/pipermail/interchange-users/2002-September/025939
.html) which refers to a 'Search reference capability', but I couldn't find
any further info?

Steve



More information about the interchange-users mailing list