in reply to Re: Switching out text only in a variable
in thread Switching out text only in a variable

Sorry, I guess I should have showed you the headers...

I am using CGI.pm:  use CGI qw(:standard :cgi-lib escapeHTML);
I guess I could just have the part where it prints the html link instead of putting &q=$_query I _could_ put a placeholder like &q={{replace_query}} then _after_ I Have it replace all the text then replace that with the original query. That just seems like a 'broken' way to do it. What do you think?

thx,
Richard

Replies are listed 'Best First'.
Re^3: Switching out text only in a variable
by diotalevi (Canon) on Nov 19, 2004 at 07:09 UTC

    Use CGI's html generation methods.

    # Assuming $q is from CGI->new my $url = $q->My::CGI::hypothetical_param( search => 'value' )->self_u +rl; sub My::CGI::hypothetical_param { my $current_q = shift; my $q = CGI->new( $current_q ); my $params = { @_ }; while ( my ( $param, $value ) = each %$params ) { if ( not defined $value ) { $q->delete ( $param ); } else { $q->param( $value ); } } $q; }