[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Dumb Newbie-ish question



At 14.54 11/17/97, Howard Soroka wrote:
> However: might I be able to incorporate the Perl source code for the
> Internet Config module into my own source, and go from there? I realize
> this might be a pain, but it might be worth a little effort. I guess the
> question is whether or not InternetConfig.pm uses OTHER stuff that can't
> be linked into a runtime file.

That is the problem, of course.  You can actually do a trick where you can
embed modules and require'd files in the resource fork of whatever runtime
you've got, but that does not work for modules with shared libraries,
AFAIK.  Here is the code that has been posted before to accomplish it,
though.

It should work for everything that does NOT require dynamically shared
libraries (which includes InternetConfig.pm).  If you want it to work with
the extra shared libraries, you can just make a new dir called "lib", and
out all the files (including proper directory structure) that you need in
there.

In this case, :lib would contain the following directories (and the full
contents of the final three directories):

:auto:
        DynaLoader:

:MacPPC:
        auto:
                Mac:
                        Types:
                        InternetConfig:

Speaking of which: the below script really should find a way to import
autoloaded subroutines (.al file) too.  Oh well.  :)

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


#"ExtractModules.dp"
#=========================================
#!perl

use Mac::Resources;
use Mac::Memory;

#ARGV now in scalar context (thanks to Bart and Chris)
$res= OpenResFile($ARGV[0]) || die $^E;

#first 'TEXT' resource is source code:
$sourceCodeRes= Get1IndResource('TEXT', 1);
$sourceCodeText= $sourceCodeRes-> get();

#clear the hash:
undef(%INC);

#suppress warnings about redefining subroutines
#by 'eval(use...)':
local $^W = 0;

#angle operator doesn't work here(?):
@sourceCodeText= split /\n/, $sourceCodeText;
for (@sourceCodeText){
        if(/^use.*;/){
                eval($_); #read the %INC
        }
}

$id= 5000;
foreach $libFileName(keys %INC) {
        $aText= "";

        open(libFile, $INC{$libFileName}) or die $^E;
        while(<libFile>){
                $aText.= $_;
        }
        $codeHand= new Handle($aText);

        #UNIX-> Mac Folder
        $libFileName=~ s/\//:/g;
        AddResource($codeHand, 'TEXT', $id, $libFileName) or die $^E;
        WriteResource($codeHand) or die $^E;;
        ReleaseResource($codeHand) or die $^E;;
        $codeHand-> dispose;
        $id++;
        print "Copied module ".$libFileName." into resource fork.\n";
}
CloseResFile($res);
sleep(3);
&MacPerl'Quit(3);

#=======================================================

Michael Ziege
Sallenbachstr. 11
8055 ZŸrich
Switzerland
tel.    ++41-1-463 82 78
e-mail. ziege@ito.umnw.ethz.ch



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch