I saw a method of doing this awhile ago where
the code was wrapped into c binary. It only prevented
novices
from viewing the code, since all you needed to do was
open the binary file and browse through it.
i have a snippet from one of my chat logs ...
/*#define MULTIPLICITY */ /* try not to be a bad boy, avoid tinkering
+with the interpreter's internal structure! */
\#include <EXTERN.h>
\#include <perl.h>
\#include <stdlib.h>
static PerlInterpreter *pi;
static char *script = $scriptText;
int main(int argc, char **argv, char **envv)
{
int l, i, p_argc;
char **p_argv;
char *e_switch = \"-e\";
char *real_name = argv[0];
char *s_argv[2] = { e_switch, script } ;
char **p_envv = envv;
p_argc = argc+2;
p_argv = (char **)malloc(sizeof(char*)*argc);
p_argv[0] = argv[0];
p_argv[1] = s_argv[0];
p_argv[2] = s_argv[1];
for(i=1;i<argc;i++)
{
p_argv[i+2]=argv[i];
}
pi = perl_alloc();
perl_construct(pi);
perl_parse(pi,NULL,p_argc,p_argv,p_envv);
{
SV *sv;
sv = perl_get_sv(\"0\",FALSE);
if (!SvOK(sv))
{
printf(\"%s: unrecoverable error\\n\",argv[0]);
exit(EXIT_FAILURE);
}
sv_setpv(sv,argv[0]);
}
perl_run(pi);
perl_destruct(pi);
perl_free(pi);
return EXIT_SUCCESS;
}
I wish i could remember what it was called or who wrote it.
I'll try and find it on my old disks
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.