>
> I found one way to get global subs in embperl.
> This is not the best way to do it but it works. The best solution is that
> embperl handle this.
Also the thing you do works, it seems a little bit complicated. Angus has send
a list of possibilities you have for calling global subs in Embperl, where
Embperl handles compilation and error handling for you. I think there should
be one method he mentioned that fits your needs.
Gerald
> The bad news with this way to get global subs is that you will need to
> evaluate the same code if you need it in different files loaded, the good
> news is that you will load your subs only once.
>
> Note. If you test this files, be carefully when copy the text. When i
> tested sending to my self i found it is better to write them again and not
> copy.
>
> Sorry for the long text.
>
> Carlos Kassab
>
> ################ file index.epl ################
> [- $globalp = shift; -]
> [- $optRawInput = 1 -]
> [-
> $globalp->{globalsubs} = "";
> $mysubsfile =
> substr($ENV{'PATH_TRANSLATED'},0,length($ENV{'PATH_TRANSLATED'})-10)."subs.
>epl"; open(MYSUBS, $mysubsfile) while(<MYSUBS>) {
> $globalp->{globalsubs} =
> $globalp->{globalsubs}.$_; }
> close(MYSUBS);
>
> $globalp->{bgcolor1} = "#efefef";
> $globalp->{bgcolor2} = "#438fff";
> eval $globalp->{globalsubs};
> -]
>
> <html> <head><title> test </title></head><body>
> [-
> local $escmode = 0;
> &OpenTable($globalp->{bgcolor1},$globalp->{bgcolor2});
> &mytitle("<big>My main title</big>");
> &CloseTable;
> -]
> <br> [- Execute ('somefile.epl') -] </body></html>
>
>
>
> ################ file subs.epl ################
>
> sub mytitle { my $title = shift; print OUT "$title"; }
>
> sub myfooter { $footertext = shift; print OUT "<u>$footertext</u>"; }
>
> sub OpenTable
> {
> $bgcolor1 = shift; $bgcolor2 = shift;
>
> print OUT "<table width=\"100%\" border=\"0\" cellspacing=\"1\"
> cellpadding=\"0\" bgcolor=\"$bgcolor2\"><tr><td>\n"
> ."<table width=\"100%\" border=\"0\" cellspacing=\"1\"
> cellpadding=\"8\" bgcolor=\"$bgcolor1\"><tr><td>\n";
> }
>
> sub CloseTable { print OUT "</td></tr></table></td></tr></table>\n"; }
>
> ################# file somefile.epl ##############
> [$ syntax EmbperlBlocks ASP $]
> <%
> $globalp = shift;
> local $escmode = 0;
> eval $globalp->{globalsubs};
> print OUT $@ if( $@ );
> &OpenTable($globalp->{bgcolor1},$globalp->{bgcolor2});
> &mytitle("<b>my subtitle</b>");
> &CloseTable;
> %>
> <p>some body text here.</p>
> <% &myfooter("footer text"); %>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]