$content=~s/\[google:\/\/([^|\]]+)\|([^\]]+)\]/&google('G',$1,$2)/eig; # [google://keyword(s)|text] $content=~s/\[google:\/\/([^|\]]+)\]/&google('G',$1)/eig; # [google://keyword(s)] $content=~s/\[lucky:\/\/([^|\]]+)\|([^\]]+)\]/&google('L',$1,$2)/eig; # [lucky://keyword(s)|text] $content=~s/\[lucky:\/\/([^|\]]+)\]/&google('L',$1)/eig; # [lucky://keyword(s)] #### sub google { # [google://] and [lucky://] my$google = 'http://www.google.com/search?q='; my$luck = '&btnI=lucky'; my($fu,$g,$n) = shift; if($fu eq 'G'){ undef($luck) } $n = CGI::escape($_[0]); if(@_ == 2){ $g = qq~$_[1]<\/a>~; } if(@_ == 1){ $g = qq~$_[0]<\/a>~; } return $g; }