thewml / website-meta-language

An old offline HTML preprocessor (which can be used for static site generation), written in Perl and C that is still maintained for legacy reasons, but probably not recommended for new sites.
https://www.shlomifish.org/open-source/projects/website-meta-language/
GNU General Public License v2.0
14 stars 8 forks source link

Undefined subroutine for Pass 3 definition #30

Closed traumschule closed 5 years ago

traumschule commented 5 years ago

Using Pass 3 fails with

ePerl:Error: Perl runtime error (interpreter rc=2)

---- Contents of STDERR channel: ---------
Undefined subroutine &main::some_name called at /tmp/wml.LkAQH_/wml.2588.tmp1.wml line 604.
------------------------------------------
** WML:Break: Error in Pass 3 (rc=1).
../Makefile.common:32: recipe for target 'debian.html.en' failed
make[1]: *** [debian.html.en] Error 1

Is this function no longer usable?

STR

At the beginning of a .wml file a subroutine is defined and later called:

<perl>
sub some_name _lbrace_

  ...

_rbrace_
</perl>

...
<:= &some_name() :>
shlomif commented 5 years ago

See http://perl-begin.org/tutorials/bad-elements/#ampersand-in-subroutine-calls .

traumschule commented 5 years ago

Unfortunately removing the ampersand didn't help. Did you see that the documentation linked above does the same? Did you try to use Pass 3 in a while? What could be the issue here?

shlomif commented 5 years ago

@traumschule : please see https://github.com/shlomif/how-to-share-code-online - give me a repo URL to clone. I use pass 3 / ePerl all the time.

traumschule commented 5 years ago

With wml 2.0.12 (16-Apr-2008) from debian stable and 2.12.0 in testing the following fails:

2.0.12

$ cat >test.wml <<EOF
      <perl>
      sub isotime _lbrace_
          my ($time) = @_;

          my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
              localtime($time);
          my ($str) = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
               $year+1900, $mon+1, $mday, $hour, $min, $sec);
          return $str;
      _rbrace_
      </perl>

      The current date is <:= &isotime(time()) :>.
EOF
$ wml test.wml
ePerl:Error: Perl runtime error (interpreter rc=255)

---- Contents of STDERR channel: ---------
Undefined subroutine &main::isotime called at /tmp/wml.cZyjms/wml.8370.tmp1.wml line 33.
------------------------------------------
** WML:Break: Error in Pass 3 (rc=1).

2.12.0

$ wml --version
Use of uninitialized value in pattern match (m//) at /usr/share/wml/TheWML/Frontends/Wml/WmlRc.pm line 48.
        TheWML::Frontends::Wml::WmlRc::_process_wmlrc(TheWML::Frontends::Wml::WmlRc=HASH(0xc892b4)) called at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 858
        TheWML::Frontends::Wml::Runner::run_with_ARGV(TheWML::Frontends::Wml::Runner=HASH(0xb8a01c), HASH(0xe0a570)) called at /usr/bin/wml line 47
This is WML Version 2.12.0
Copyright (c) 1996-2001 Ralf S. Engelschall.
Copyright (c) 1999-2001 Denis Barbier.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

$ wml test.wml
ePerl:Error: Perl runtime error (interpreter rc=255)

---- Contents of STDERR channel: ---------
Undefined subroutine &main::isotime called at /tmp/wml.18959.tmp1 line 28.
------------------------------------------
** WML:Break: Error in Pass 3 (rc=1).
Died at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 403.
        TheWML::Frontends::Wml::Runner::_run_pass(TheWML::Frontends::Wml::Runner=HASH(0x226301c), 3, SCALAR(0x25a62b8), SCALAR(0x25a6290), SCALAR(0x25a62a4)) called at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 441
        TheWML::Frontends::Wml::Runner::_passes_loop(TheWML::Frontends::Wml::Runner=HASH(0x226301c)) called at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 726
        TheWML::Frontends::Wml::Runner::_output_and_cleanup(TheWML::Frontends::Wml::Runner=HASH(0x226301c)) called at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 930
        TheWML::Frontends::Wml::Runner::run_with_ARGV(TheWML::Frontends::Wml::Runner=HASH(0x226301c), HASH(0x2500d0c)) called at /usr/bin/wml line 47
shlomif commented 5 years ago

@traumschule : this wml file works:

      <:
      sub isotime {
          my ($time) = @_;

          my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
              localtime($time);
          my ($str) = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
               $year+1900, $mon+1, $mday, $hour, $min, $sec);
          return $str;
      }
      :>

      The current date is <:= &isotime(time()) :>.

are you sure one does not need a wml include to get the <perl> macro working?

traumschule commented 5 years ago

This works for me, thanks!

shlomif commented 5 years ago

On Sat, 12 Jan 2019 21:18:49 -0800 Traumschule notifications@github.com wrote:

This works for me, thanks!

you're welcome.

--

Shlomi Fish http://www.shlomifish.org/ http://shlomifishswiki.branchable.com/Encourage_criticism_and_try_to_get_offended/

Bigamy: Having one wife too many. Monogamy: The same thing! — Unknown source.

Please reply to list if it's a mailing list post - http://shlom.in/reply .