... The Syntiac Pages ...
  home
Synthesizers
FPGAs
Games
Software
    software
    PerlWeb
Hardware
Pinball
Tech
 
  
 
  Downloads
perlweb (20100324)
 
  
     

PerlWeb a httpd in Perl

PerlWeb is a complete http server written in a single Perl file. It doesn't need any special modules and should run on any OS that supports TCP/IP sockets and has a port of Perl 5 for it. It is tested and known to work on both Linux and Windows XP. Unlike many other servers it doesn't use the fork system call. Still it can handle many connections and requests at the same time. On some systems you need special rights to open sockets on certain ports. By default PerlWeb is configured to use port 8888 to prevent any problems.

PerlWeb supports various mime types that are determined based on the extension of the filename. Files are streamed from disk when possible, so the amount of memory used is low. When an exact object can not be found various variations on the filename with extensions html, htm and www are tried. The www extension is treated differently. Files with the .www extension are loaded into memory and are processed with a small macro-language. This macro-language does some simple string replacements and can for example include other files. This opens the door for templates so the layout of the website can be separated from the content and stored in a separate file or files.


The macro language

\\

Many of the macros start with a backslash. If your text must contain backslashes simply double them. This prevents the backslash to be interpreted as part of a command.

\include{<filename>}

Include an other file, the contents of that file replaces the include command. Nesting of the include command is supported, so include files can themself use include files. This is the first step of the processing so the filenames are static and can not be the result of macro substitution.

\<macro-name>={<content>}

Define a new macro with the name given. The content can be any part of a webpage and can use include commands and macro substitutions. The content may contain '{' and '}' as long as they are properly balanced. Macros can be defined and used in any order. PerlWeb will scan the file for all macros and collect them before starting replacing any text.

\<macro-name>{}

Insert the content that belongs to the specified macro. The order of use and definition is unimportant. This means a template can use a macro that is defined later in another file. If a macro is not defined and used a empty string is used as replacement text and an error message is written to the stdout.

[[<link>]] or [[<link>|<name>]]

Local or remote link. If specified link is just a name a local link is created. When a protocol is specified like http:// the link is remote. A name that is separated from a link by a vertical bar (pipe) is optional. Examples:
[[page2]]
[[index.html|Home]]
[[http://google.com|search]]
If your text must contain '[' characters prefix the them with a backslash like this '\['. This will prevent the creation of accidental links.

----

Insert a horizontal ruler <hr> into the page. It doesn't save any typing, but it is easier to read. This command only works when it stands alone on a line.

==<header text>==

This command makes a h1 header with the given header text.

===<header text>===

This command makes a h2 header with the given header text.

====<header text>====

This command makes a h3 header with the given header text.
     
 
     ... The Syntiac Pages ...
www.syntiac.com/software_perlweb.html | Questions? mail: pwsoft@syntiac.com | Copyright 2000-2014 by Peter Wendrich