Re: caller information

Wolfgang Schnerring <[email protected]> Thu, 16 Oct 2003 15:37:18 +0200
Newsgroups gmane.comp.web.wml
Message-ID <[email protected]>
* Axel Rose <[email protected]>:
> The content was last modified
> #include "my-mod-info.pl" file="content.html"

Hmm. This won't answer your question directly, but this will (most
probably) solve the task you presented:

##
# displays the MTIME of given file, or of current file if no file given
##
<define-tag mtime whitespace="delete">
<preserve file/>
<set-var %attributes />
<:
use POSIX qw(strftime);
my $file = qq+<get-var file>+;
if ($file) {
($mtime) = (stat("$file"))[9];
} else {
$mtime = $WML_SRC_TIME;
}
print strftime("%d.%m.%Y", localtime($mtime));
:>
<restore file/>
</define-tag>

Usage: The content was last modified <mtime file="content.html">

> "my-mod-info.pl" is a Perl script which produces file system
> information. Called with a file parameter it checks the
> included "content.html" otherwise it checks the caller.
> How could I possibly find out who the caller is?
> Do I need a different mechanism here?

I haven't thought this through, but from the wml_p1_ipp manpage:

,----------
|      The strings ""__FILE__"" and ""__LINE__"" are always
|      substituted by the currently processed include file and the
|      current line number.
`----------

So you should be able to do this:

#include "my-mod-info.pl" file="__FILE__"

if you want the current file checked.

Hope this helps,
Wolfgang

_____________________________________________________________________
Website META Language (WML)                         http://thewml.org
User Support Mailing List                        [email protected]
Automated List Manager                            [email protected]