Here is how you might rewrite that code
#!/usr/bin/perl -- use strict; use warnings; { use CGI qw~ -nph :standard ~; my $BasePath = 'D:/finalfantasyinfo/community'; print header, start_html; MyNewsBoardApp::PrintSomeNews("$BasePath/boards/news.txt"); print end_html; exit; } package MyNewsBoardApp; use strict; use warnings; use POSIX; sub PrintSomeNews { my $NewsBoardFile = shift; my @NewsBoard = GetNewsBoard($NewsBoardFile); my $i = 0; while ( $i < 4 ) { print PostToHtml( GetNewsPost( $NewsBoard[$i][0] ) ); $i++; } } sub GetNewsBoard { use autodie qw' open close '; open my $NewsFh, shift; my @News = map { [ split /\|/, $_ ] } sort { $b <=> $a } <$NewsFh>; close $NewsFh; return @News; } sub GetNewsPost { use autodie qw' open close '; open my $NewsFh, shift; my $News = join '', $NewsFh; close $NewsFh; return split /\|/, $News; } sub PostToHtml { my (@News) = @_; my $ID = $News[3]; my $Time = POSIX::strftime( q!%H:%m %p on %B, %Y!, localtime( $New +s[3] ); $News[8] =~ s/\[(\/)?(b|u|i)\]/<$1$2>/gi; $News[8] =~ s~\[center](.*?)\[/center]~<center>$1</center>~gi; $News[8] =~ s~\[url=(\S+?)\](.*?)\[/url\]~<a href="$1">$2</a>~gi; $News[8] =~ s~\[img](.*?)\[/img\]~<img src="$1" alt="" />~gi; $News[8] =~ s~\s*\[\*\]~</li><li>~isg; $News[8] =~ s~\[olist\]~<ol>~isg; $News[8] =~ s~\s*\[/olist\]~</li></ol>~isg; $News[8] =~ s~</li><ol>~<ol>~isg; $News[8] =~ s~<ol></li>~<ol>~isg; $News[8] =~ s~\[list\]~<ul>~isg; $News[8] =~ s~\s*\[/list\]~</li></ul>~isg; $News[8] =~ s~</li><ul>~<ul>~isg; $News[8] =~ s~<ul></li>~<ul>~isg; $News[8] =~ s~\[ch9679\]~&#9679\;~isg; return qq~<p class="center"><span class="header">$News[0]</span> <br />Posted by: $News[1] at $Time</p> <p>$News[8]</p> <p style="text-align: right"><a href="http://www.ffinfo.com/community/YaBB.pl?num=$ID">Discuss this po +sting. </a></p>~; } __END__
For debugging you should use print escapeHTML( Dumper( $var, \@var, \%var ) );

See autodie, POSIX


In reply to Re^3: Scripts work under perl .exe but not ISAPI by Anonymous Monk
in thread Scripts work under perl .exe but not ISAPI by Eagle_f91

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.