Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I just fell face forward into this earlier today (sorry for the extremely long lines):
use vars qw/ + + $AllowFullYearView + + $LevelForRobotsDetection $LevelForWormsDetection $LevelForBrowsersDete +ction $LevelForOSDetection $LevelForRefererAnalyze + $LevelForFileTypesDetection $LevelForSearchEnginesDetection $LevelForK +eywordsDetection + /; ($AllowFullYearView, $LevelForRobotsDetection, $LevelForWormsDetection, $LevelForBrowsersD +etection, $LevelForOSDetection, $LevelForRefererAnalyze, $LevelForFileTypesDetection, $LevelForSearchEnginesDetection, $LevelF +orKeywordsDetection)= (2,2,0,2,2,2,2,2,2); use vars qw/ + + $DirLock $DirCgi $DirConfig $DirData $DirIcons $DirLang $AWScript $Arc +hiveFileName + $AllowAccessFromWebToFollowingIPAddresses $HTMLHeadSection $HTMLEndSec +tion $LinksToWhoIs $LinksToIPWhoIs + $LogFile $LogType $LogFormat $LogSeparator $Logo $LogoLink $StyleSheet + $WrapperScript $SiteDomain + $UseHTTPSLinkForUrl $URLQuerySeparators $URLWithAnchor $ErrorMessages +$ShowFlagLinks + /; ($DirLock, $DirCgi, $DirConfig, $DirData, $DirIcons, $DirLang, $AWScri +pt, $ArchiveFileName, $AllowAccessFromWebToFollowingIPAddresses, $HTMLHeadSection, $HTMLEnd +Section, $LinksToWhoIs, $LinksToIPWhoIs, $LogFile, $LogType, $LogFormat, $LogSeparator, $Logo, $LogoLink, $Sty +leSheet, $WrapperScript, $SiteDomain, $UseHTTPSLinkForUrl, $URLQuerySeparators, $URLWithAnchor, $ErrorMessa +ges, $ShowFlagLinks)= ('','','','','','','','','','','','','','','','','','','','','','','' +,'','','','');
etc for several pages, followed by:
#--------------------------------------------------------------------- +--------- + # Function: Write on ouput header of HTML page + + # Parameters: None + + # Input: %HTMLOutput $PluginMode $Expires $Lang $StyleS +heet $HTMLHeadSection $PageCode $PageDir + # Output: $HeaderHTMLSent=1 + + # Return: None + + #--------------------------------------------------------------------- +--------- + sub html_head { my $dir=$PageDir?'right':'left'; if (scalar keys %HTMLOutput || $PluginMode) { my $MetaRobot=0; # meta robots + + my $periodtitle=" ($YearRequired".($MonthRequired ne 'all'?"-$Mont +hRequired":"").")"; # Write head section + + if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') +{ if ($PageCode) { print "<?xml version=\"1.0\" encoding=\"$PageCode\"?>\n"; } else { print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; } ; if ($FrameName ne 'index') { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//E +N\" \"\">\n"; } else { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset/ +/EN\" \"\">\n"; } print "<html xmlns=\"\" xml:lang=\"$ +Lang\">\n"; } else { if ($FrameName ne 'index') { print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitio +nal//EN\">\n\n"; } else { print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset/ +/EN\">\n\n"; } print "<html lang='$Lang'".($PageDir?" dir='rtl'":"").">\n"; } print "<head>\n"; print "<meta name=\"generator\" content=\"AWStats $VERSION from co +nfig file awstats.$SiteConfig.conf (\" + />\n"; if ($MetaRobot) { print "<meta name=\"robots\" content=\"".($FrameName eq 'mainlef +t'?'no':'')."index,nofollow\" />\n"; } else { print "<meta name=\"robots\" content=\"noindex,nofollow\" />\n"; }
and so on for more than 10,000 lines - in one file.

Note the way arguments are passed to a function: in global variables, and the neat way of printing just one line per print statement (OK: in all fairness later the author has discovered here-docs, but he has not refactored).
And of course it is a CGI program, but does not use CGI;.

I was trying to find a web-log-analyser tool with nice pictures for the PHBs, and google pointed me towards a site on sourceforge, where a well-documented tool was available in perl, with all the nice graphs management likes.

I recoiled in horror on looking inside the code and discovering a true treasure-trove for the perlmonks Pearls (or not) - a sample of which I just had to share.
I will now go on my way and find something better or (yuck) do it myself. Pity - it did look promising, and I am lazy and impatient.

All names withheld to protect the unnamed author.

In reply to Horrors abound by htoug
in thread Pearls (not really) of Perl programming by PetaMem

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (4)
    As of 2018-06-18 08:31 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (109 votes). Check out past polls.