Skip to content

Miscellaneous

Things to note or information not otherwise contained elsewhere:

How to check syntax of a PSP file

To check the syntax of a PSP file - or more specifically any Perl code in the __PERL__ section - you can use the wdlint command. Take this file with an assignment syntax error in the server_time() routine:

<start_html>
Hello World <? server_time() ?>
__PERL__
#!perl

sub server_time {
    my 2==1; #Error here
}

Run the commandwdlint <filename.psp> to check for syntax error and report back:

$ wdlint check.psp 
syntax error at check.psp line 8, near "my 2"
check.psp had compilation errors.
How to pass $self ref if using processing instructions

If you use the processing instruction form of calling a perl method it will not pass the WebDyne object ref through to your code. You can pass it by supplying @_ as a parameter, or just shift() and your own parameters:

<start_html>
Hello World <? server_time(@_) ?>
Hello World <? server_time(shift(), 'UTC' ?>
Hello World <perl handler="server_time" param="UTC"/>
__PERL__

sub server_time {
    #  Now we can get self ref
    my ($self, $timezone)=@_;

    #  Do something and return
    $self->do_something()
}
Use of hash characters for comments in PSP files

Any # characters at the very start of a PSP file (before a <html> or <start_html>) tag are treated as comments and discarded - they will not be stored or displayed (they are not translated into HTML comments). This allows easy to read comments at the start of PSP files. Any # characters after the first valid tag are not treated specially - they will be rendered as normal HTML:

#  This is my server time display file
#  
#  VERSION=1.23
#
<start_html>
Server local time is: <? localtime ?>
The <checkbox> tag will always set a hidden form field

The <checkbox> tag is unusual in that it adds a hidden field (with the same name as the checkbox) to the HTML page to retain state. Thus if you are examining the checkbox parameter from CGI via $_{'checkbox_name'} or $self->CGI->param('checkbox_name') you may get an array rather than a single value. The value of the checkbox (boolean, checked or unchecked, i.e. 1 or 0) will always be the first value returned. So the code if ($_{'checkbox_name'}) { .. do_something } will work as expected - but just be careful if using in an array context.

About this documentation

This documentation is written with the XMLMind XML Editor, then converted to Markdown with pandoc and displayed using MKdocs. The documentation for WebDyne is maintained on a Github repository.