LiTinOveWeedle has asked for the wisdom of the Perl Monks concerning the following question:
<a href="http://my.domain.com" group="1,2,5">This URL</a>
scipts validate users from cookie (in which it found usergroup value) Now script should check all hyperlink - if usergroup (which was in the cookie) is in html hyperlink as: group="value" then remove group parameter from it and print simple this:
<a href="http://my.domain.com">This URL</a>
If not script should print only This URL. There is several hyperlink in html template.
So expect that I get from cookie usergroup value and read html source from file into the $html.
$html =~ s/<a href="(.*?)" group="(.*?)">(.*?)</a>/&change($1, $2, $3) +/isge; print $html; sub change { my ( $group, $temp, $url, $hyp, @groups ); $url = @_[0]; $hyp = @_[2]; @groups = split( /,/@_[1] ); foreach $group (@groups) { if ($group == $usergroup) { $temp = "<a href=\"$url\">$hyp</a>"; return $temp; } return $hyp; } }
This is long version I know that it can be written by short way but this is test... Its working in some case but in some not. Sometimes it print only part of my template, sometimes all. It depent on html template source. When all hyperlinks have groups parameter results is different from when only some hyperlinks have group parameter... So probably problem will be in regex..... I read Death to dot star from Ovid but doesn't found answer in it....
So If you know something.... I wrote code from my memory So I hope that it's allright...
Li Tin O've Weedle
mad Tsort's philosopher
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex and dot to star
by andye (Curate) on Apr 03, 2001 at 13:28 UTC | |
by LiTinOveWeedle (Scribe) on Apr 03, 2001 at 14:16 UTC | |
by tilly (Archbishop) on Apr 04, 2001 at 04:54 UTC | |
by LiTinOveWeedle (Scribe) on Apr 03, 2001 at 22:08 UTC | |
|
Re: regex and dot to star
by physi (Friar) on Apr 03, 2001 at 13:10 UTC | |
by LiTinOveWeedle (Scribe) on Apr 03, 2001 at 13:22 UTC |