🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.perl
Article #497

Re: Podświetlenie tekstu w PERLu

#497
From: Jaroslaw Strzalkowski
Date: Sat, 09 Aug 1997 16:54
55 lines
1691 bytes
In pl.comp.lang.perl Adam Twardoch (fidel) <adam.twardoch@euv-frankfurt-o.de> wrote:
: Drodzy!
: Sytuacja: PERL. Serwer WWW na stacji Unix. CGI. 
: Mam dokument HTML i mam pewne wyrażenie. 
[...opis problemu...]

: Jak to zrobić w PERLu?

Popatrz na to poniżej - to jeszcze nie całkiem doszlifowane, ale w zasadzie
robi to co chcesz - dopieść to sobie tak jak chcesz. Komentarze są chyba
niepotrzebne - dość banalne to, nieprawdaż?
Pozdrowienia.


#!/usr/local/bin/perl

undef $/;
$_ = <STDIN>;
if( /(<body>)(.+)(<\/body>)/is ) 
{ 
  $before_body = $`.$1; 
  $body = $2;
  $after_body = $3.$';
}
else
{
  $body = $_;
}

print $before_body;

while( $_ ne '' )
{
  if( /^([^<]*)(<[^>]*>)/s )
  {
    $nietag = $1;
    $tag = $2;
    $_ = $';
  }
  else
  {
    $nietag = $_;
    $tag = '';
    $_ = '';
  }

  $nietag =~ s/(font\w*)/<FONT COLOR="red">$1<\/FONT>/igs;
  print $nietag . $tag;
}


print $after_body;

-- 
Jaroslaw Strzalkowski, Uczelniane Centrum Informatyki AGH, Krakow
Technical Details
Message-ID: <5si7cm$7l7$1@galaxy.uci.agh.edu.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!agh.edu.pl!not-for-mail
References: <33EB8701.9797E423@euv-frankfurt-o.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!agh.edu.pl!not-for-mail
From: js@galaxy.uci.agh.edu.pl (Jaroslaw Strzalkowski)
Newsgroups: pl.comp.lang.perl,pl.comp.www
Subject: Re: Podświetlenie tekstu w PERLu
Date: 9 Aug 1997 18:54:46 +0200
Organization: University of Mining & Metallurgy
Lines: 55
Message-ID: <5si7cm$7l7$1@galaxy.uci.agh.edu.pl>
References: <33EB8701.9797E423@euv-frankfurt-o.de>
NNTP-Posting-Host: galaxy.uci.agh.edu.pl
Mime-Version: 1.0
X-Newsreader: TIN [UNIX 1.3 unoff BETA 970307; sun4m SunOS 5.5.1]
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit