Forum Moderators: coopster & phranque

Message Too Old, No Replies

[perl] testing [/perl]

         

Brett_Tabke

5:20 pm on Sep 1, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Experimenting with a new support code for this forum. It is the [ perl ] insert script here [ /perl ] code. I have hacked around on Pretty Perl module by Roman Kosenko. It's available from CPAN, but it is intended for unix/mod_perl only.

[cpan.org...]

[perl]
package "perl";
#----------- comment
$u =~ s!\=http!http!gi;
@ebean =("foo");
$enterprise=0;
print "<li>";
foreach $word (@searchwords) {
if ($title =~ /$word/ig) {
print " <font face=arial color=red> ** $word ** ";
push(@flag,$i);
$found++;
$stfound++; #---------- comment
}
}
[/perl]

Brett_Tabke

5:26 pm on Sep 1, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Multi scripts per post test
[perl]
#------------------------------------------------------ split record
sub splitrecord {
my ($tt)=@_;
($linkurl,
$linkrealurl,
$linksource,
$linktitle,
$linkpublisher,
$linktime,
$linkreserved) = split(/\s*\¦\s*/,$tt);

&convert_time($linktime);
$wmod = $ttime . " " .$wordtime;
}

#---------------------------------------------
[/perl]

This line should not be highlighted, but in verdana at 2.

[perl]
$TAB = 8 unless $TAB;
($i,$tmp,@str,$b,$e);
$_ = $data;
$b = $e = pack("LL", ());
# s:(&):&:g;
s:>:>:g; s:<:<:g;
# Spaces and newlines
s:(\n¦\r):<BR>$&:gm;
s:\t:" " x $TAB:egm;
s:^\s+¦\s{2,}:(" " x (length($&) - 1))." ":egm;

[/perl]

Brett_Tabke

6:07 pm on Sep 1, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



test

Bolotomus

5:37 pm on Sep 6, 2001 (gmt 0)

10+ Year Member



Cool!! But lets see how good the parser REALLY is

[perl]
s**'@z!~;()=~$x>;%x>l;$(,<x>'*e;y*%z),$;@=<x>!;h(l~;*punch jokers;halt;*;print;
[/perl]

(If you want a good laugh, type this program in and run it. It's harmless, I promise.)

(edited by: Bolotomus at 5:44 pm (gmt) on Sep. 6, 2001

Bolotomus

5:43 pm on Sep 6, 2001 (gmt 0)

10+ Year Member



Seems pretty good, but I think it drops the ball a little bit on
expressions like the second one below:

[perl]
$llama = '<X>."hello"';
$camel =~ s/<X>."hello"/llama/g;
[/perl]

It is correct when it makes <X>."hello" all one color; they are merely a string and should not get color-parsing. But in the second line, when that stuff is in a regex, suddenly it tries to parse it as if it's perl code that might be executed.

Brett_Tabke

5:48 pm on Sep 6, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Off the shelf module Bolo.

One side effect is that I had to turn off the other enhancements such as bold and italic. I could have parsed them out, but once I get into that code it's already exception after exception to the other 14 exceptions.

I wasn't so interested in the syntax colorization as I was keepin the users code indentions.