Article View: pl.comp.lang.perl
Article #1393Re: Nietypowy Search Engine
From: Marek Jedlinski
Date: Sat, 23 May 1998 23:59
Date: Sat, 23 May 1998 23:59
48 lines
2186 bytes
2186 bytes
Jacek Kubica <webmaster@zdo.wssk.am.wroc.pl> wrote: >Zalozenie: szukasz $query w linii $line > >Przyklad (ktory dziala!) > >#!/usr/local/bin/perl >$query = "pErL"; >$line = "Chetnie ucze sie Perla, bo lubie Perla"; >$temp = $line; >$query =~ y/[A-Z]/[a-z]/; >$temp =~ y/[A-Z]/[a-z]/; >$pocz = index($temp,$query); >$dlugosc = length($query); >$wyraz = substr($line,$pocz,$dlugosc); >$line =~ s/$query/<b>$wyraz<\/b>/gi; >print $line; > >========================================= >Wynik : "Chetnie ucze sie <b>Perl</b>a , bo lubie "<b>Perl</b>a Ale to mozna uproscic i nie uzywac zadnych dodatkowych zmiennych, oprocz tych, ktore Perl i tak dla nas definiuje (tutaj akurat $1). Na przyklad tak: #!/usr/local/bin/perl -w $line = "Chetnie ucze sie Perla, bo PERL jest cool i lubie Perla"; $query = "pErL"; $line =~ s/($query)/<B>$1<\/B>/gi; print "$line\n"; ========================================= wynik: Chetnie ucze sie <B>Perl</B>a, bo <B>PERL</B> jest cool i lubie <B>Perl</B>a Ja tez nie jestem pewien, czy dokladnie o to chodzilo, ale rezultat wykonania skryptu jest identyczny z rezultatem Jacka :-) .marek -- After things go from bad to worse, the cycle will repeat itself. http://come.to/fnord/
Technical Details
Message-ID:
<3567417f.25418598@news.nask.org.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.nask.pl!not-for-mailReferences:
<6j5bve$gql$1@sunsite.icm.edu.pl> <6j7lmm$591$1@galaxy.uci.agh.edu.pl> <6j9e4m$sol$1@sunsite.icm.edu.pl> <Pine.LNX.3.96.980512174353.25001D-100000@qrnik.knm.org.pl> <6jaefe$e5b$1@sunsite.icm.edu.pl> <35596CA1.C9B44773@zdo.wssk.am.wroc.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.nask.pl!not-for-mail From: cicho@polbox.com (Marek Jedlinski) Newsgroups: pl.comp.lang.perl Subject: Re: Nietypowy Search Engine Date: Sat, 23 May 1998 23:59:59 GMT Organization: General Frenetics, Discorp., http://come.to/fnord/ Lines: 51 Message-ID: <3567417f.25418598@news.nask.org.pl> References: <6j5bve$gql$1@sunsite.icm.edu.pl> <6j7lmm$591$1@galaxy.uci.agh.edu.pl> <6j9e4m$sol$1@sunsite.icm.edu.pl> <Pine.LNX.3.96.980512174353.25001D-100000@qrnik.knm.org.pl> <6jaefe$e5b$1@sunsite.icm.edu.pl> <35596CA1.C9B44773@zdo.wssk.am.wroc.pl> NNTP-Posting-Host: pmone253.lodz.pdi.net Mime-Version: 1.0 Summary: If this makes sense to you, you have a big problem. Keywords: If you're happy and you know it, clunk your chains. X-Newsreader: Forte Agent 1.5/32.451 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit