Gossamer Forum
Home : General : Perl Programming :

Perl url replacing problems

Quote Reply
Perl url replacing problems
Hi, my perl-knowledge is not very good so hopefully someone here can help me.

what I want to do seems quite simple: replacing an url.

This is what I have:

$url is fetched from a database-field:
[http://www.otherdomain.com/adserver/adclick.php?n=a42caa8f]

$text_gen is also fetched from a database-field :

[<a href="http://www.otherdomain.com/adserver/adclick.php?n=a42caa8f" target="_blank"><img src="http://www.otherdomain.com/adserver/adview.php?what=zone:329&amp;n=a42caa8f" border="0" alt="">]

===================
my perl-code to replace the $url in $text_gen by $kod:
===================
....
my $url=$row_html->[1];
my $kod="http://www.domain.com?hbid=13";
$text_gen=~s/$url/$kod/gs;
.....

===================

unfortunately the link-url isn't replaced and I don't know why.

if I have an URL in $url and $text_gen like " http://www.domain.com/index.html " then it works!


Any comments?

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.

Last edited by:

ManuGermany: Mar 5, 2004, 3:23 AM
Quote Reply
Re: [ManuGermany] Perl url replacing problems In reply to
This should work;

Code:
$text_gen =~ s|\Q$url|$kod|g;

The \Q is the important part. It lets you tell the regex engine that you don't want to parse any of the normal regex charachters, such as .'s [] etc.

Hopefully that should work :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Mar 5, 2004, 3:47 AM
Quote Reply
Re: [Andy] Perl url replacing problems In reply to
Thanks Andy,

but unfortunately this doesn't work, too.

I can't see any effect.
It's still the same as described above.

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] Perl url replacing problems In reply to
Odd. How about the modified version?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [ManuGermany] Perl url replacing problems In reply to
Also, give some debugging codes a go... Something like;

Code:
print "Content-type: text/html \n\n";
print q|$text_gen - <BR><BR>| . $text_gen . "<BR><HR>";
print q|$url - <BR><BR>| . $url . "<BR><HR>";
print q|$kod - <BR><BR>| . $kod . "<BR><HR>";

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Perl url replacing problems In reply to
Hi Andy,

I was extremly stupid!

Your hint with the \Q works!!

For it's not my script I'm editing I was at the wrong place in the script. The function where I tried the code isn't used any more but know (after the update) another one.

It works!!!

Many thanks!!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] Perl url replacing problems In reply to
Glad to hear it :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates