ActiveState Powered by ActiveState

ActiveState Community


Making expiring ("time bombed") executables with PerlApp.

Posted by troyt on 2007-03-01 14:02
OS: All / Any | Product: Perl Dev Kit | tags: perlapp
Question:

Can I put a time limit on my executeable which I create with PerlApp?

Answer:

Yes. This sample program will run normally when you invoke it as `perl expire.pl`, but will refuse to run after the expiration date when it has been compiled with PerlApp.

You could hard-code the expiration data in your program, or you can supply it when you build the executable and retrieve it inside your application from a bound file:

BEGIN {
    return unless defined $PerlApp::VERSION;
    my $expire = PerlApp::get_bound_file("expire") or return;
    my($y,$m,$d) = (localtime)[5,4,3];
    my $today = sprintf("%04d-%02d-%02d", $y+1900,$m+1,$d);
    return if $today le $expire;
    print "expired\n";
    exit;
}
print "ok\n";

For example:

c:\tmp> date /t
Wed 02/14/2007 

c:\tmp> perlapp -f --nologo --bind expire[data=2007-02-13] expire.pl

c:\tmp> expire
expired

c:\tmp> perlapp -f --nologo --bind expire[data=2007-02-14] expire.pl

c:\tmp> expire
ok
-->