On 22 Feb 2004 at 12:38, Xavier Noria wrote:

> I am just starting with PAR and got a few questions after reading the 
> docs:
> 
> I want to distribute an application + data files both packaged and 
> unpackaged. Can a script know whether it's being running from within a 
> PAR file to decide how to read the data files?
> 

How about:

    if (exists $PAR::LibCache{$0}) {
        print "this perl is inside a PAR\n";
    }
    else {
        print "what's a PAR?\n";
    }

> If the application itself was a PAR file foo.par containing the 
> executable foo.pl, and that application was bundled with data files in 
> a second PAR bar.par, is there a way to execute foo.pl when bar.par is 
> called?
> 

Not sure what you mean? Call a data file?

> This application will need to recreate some dir tree in disk (data 
> files). Can packaged programs leverage PAR's temp dir somehow or would 
> it be better to read_file() and manage a custom temp dir by hand?
> 

$ENV{PAR_TEMP} gives you the temp dir in use. You could always unzip all of bar.par 
there if you like. You would have to do subdir cleanup if you want "pp -C" to work.

> Are paths to files in PAR archives using forward slashes portable?

PARs are Archive::Zip files. From the Archive::Zip doc:

FILE NAMING

Regardless of what your local file system uses for file naming, names in a Zip file 
are in Unix
format (forward slashes (/) separating directory names, etc.). Archive::Zip tries to be
consistent with file naming conventions, and will translate back and forth between 
native and
Zip file names. However, it can't guess which format names are in. So two rules 
control what
kind of file name you must pass various routines:

Names of files are in local format.
    File::Spec and File::Basename are used for various file operations. When you're 
referring
    to a file on your system, use its file naming conventions.

Names of archive members are in Unix format.
    This applies to every method that refers to an archive member, or provides a name 
for new
    archive members. The extract() methods that can take one or two names will convert 
from
    local to zip names if you call them with a single name.



Alan Stewart

Reply via email to