Preprocess file before displaying

  • nicolac
  • Born
  • Born
  • nicolac
  • Posts: 1

Post 3+ Months Ago

Being very weak with Perl I'm trying to modify a search engine which links directly to a file (see existing code):

Code: [ Select ]
  &html_header("Your Search Results");
  print "The following Items might be relevant to your search topic.\n";
  print " You Searched for <strong>$items</strong>\n";
  print "<hr><dl><dt>\n";
  for $r ( 0 .. $#results ) {
   for $d ( 0 .. $#{$results[$r]} ) {
    select(STDOUT);
    $_ = $results[$r] [$d];
    ($link) = split(/\"/, $_);
    $ymd=substr $_,0,8;
    $y=substr $_,0,4;
    $m=substr $_,4,2;
    $d=substr $_,6,2;
    $title=substr $_,9,31;
    $title =~ s/.HTML/ /ig;
    $title =~ s/_/ /ig;
    ($title,$rest)=split /\//, $title;
    if (-d $y) {
     print qq|<dd><a href=\"$baseurl$y\/$link\">$m-$d-$y $title</a><br>\n|;
    } else {
     print qq|<dd><a href=\"$baseurl$link\">$m-$d-$y $title</a><br>\n|;
    }
   }
  }
  print "</dl><P>\n";
 }
 &html_trailer;
}
  1.   &html_header("Your Search Results");
  2.   print "The following Items might be relevant to your search topic.\n";
  3.   print " You Searched for <strong>$items</strong>\n";
  4.   print "<hr><dl><dt>\n";
  5.   for $r ( 0 .. $#results ) {
  6.    for $d ( 0 .. $#{$results[$r]} ) {
  7.     select(STDOUT);
  8.     $_ = $results[$r] [$d];
  9.     ($link) = split(/\"/, $_);
  10.     $ymd=substr $_,0,8;
  11.     $y=substr $_,0,4;
  12.     $m=substr $_,4,2;
  13.     $d=substr $_,6,2;
  14.     $title=substr $_,9,31;
  15.     $title =~ s/.HTML/ /ig;
  16.     $title =~ s/_/ /ig;
  17.     ($title,$rest)=split /\//, $title;
  18.     if (-d $y) {
  19.      print qq|<dd><a href=\"$baseurl$y\/$link\">$m-$d-$y $title</a><br>\n|;
  20.     } else {
  21.      print qq|<dd><a href=\"$baseurl$link\">$m-$d-$y $title</a><br>\n|;
  22.     }
  23.    }
  24.   }
  25.   print "</dl><P>\n";
  26.  }
  27.  &html_trailer;
  28. }


----------So that I can highlight each occurrence of one of the arguments, such as:

Code: [ Select ]
while (<>)
{
 $flag=0;
 @words=split(/[( )(.)(,)(;)]/,$_);
 foreach $word (@words)
  {
  if($word eq "$query[1]")
   {
   $flag=1;
   }
  }
 if($flag eq 1)
  {
  print "<font color=red>";
  print $_;
  print "</font>";
  }
  else
  {
  print $_;
  }
}
  1. while (<>)
  2. {
  3.  $flag=0;
  4.  @words=split(/[( )(.)(,)(;)]/,$_);
  5.  foreach $word (@words)
  6.   {
  7.   if($word eq "$query[1]")
  8.    {
  9.    $flag=1;
  10.    }
  11.   }
  12.  if($flag eq 1)
  13.   {
  14.   print "<font color=red>";
  15.   print $_;
  16.   print "</font>";
  17.   }
  18.   else
  19.   {
  20.   print $_;
  21.   }
  22. }
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Borrow -A- Geek
  • Professor
  • Professor
  • User avatar
  • Posts: 763
  • Loc: Dallas/Ft Worth, Texas

Post 3+ Months Ago

Welcome to Ozzu... this sounds like a good question for BigWeb himself!...
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

definitely! BIGWEB?!

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 25 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.