Hello Bret,

Thank you for your asnwer!

It seems that's the most elegant solution possible (though it's not obvious
to me why it doesn't work on UNIX when using PATH lookup).

 Though it may be useful to add an option to 'pp' to include 'main.pl'
with the body of the script you've quoted, in order to avoid reinventing
the wheel by everybody.

 Best regards,
  -Vlad

On Sun, May 09, 2004 at 09:18:19AM -0400, Bret Aarden wrote:
> 
> Vlad,
> 
> My solution to the problem is to add a script named 'foo' to the 
> package which is roughly the same as the normal 'main.pl' script 
> that's embedded in all PAR archives. See my version below.
> 
> This works fine on Windows, and when invoked in UNIX using a full pathname.
> 
> But it doesn't work under UNIX when invoked via PATH lookups. Then 
> the 'foo' script is ignored and the 'main.pl' script is used instead. 
> (This is true for both RH Linux using PAR 0.80, and Mac OS X using 
> PAR 0.69.)
> 
> AFAIK, there is no way to edit 'main.pl' and still have a working PARchive.
> 
> Best,
> -Bret Aarden.
> 
> ===
> 
> if (@ARGV == 0) {
>   die <<END;
> 
> (usage text)
> 
> END
> }
> 
> my $file = shift @ARGV;
> my $zip = $PAR::LibCache{$0} || Archive::Zip->new(__FILE__);
> $file =~ s/^.*[\/\\]//;
> $file =~ s/\.[^.]*$//i ;
> my $member = eval { $zip->memberNamed($file) }
>         || $zip->memberNamed("$file.pl")
>         || $zip->memberNamed("script/$file")
>         || $zip->memberNamed("script/$file.pl")
>     or die qq("$file" is an unknown command. ) .
>       qq(Use "$0" without arguments for help.\n);
> PAR::_run_member($member, 1);
> 
> 
> >Documentation for 'pp' states the following:
> >
> >           % pp -o foo foo.pl bar.pl   # Pack 'foo.pl' and 'bar.pl' into 
> >           'foo'
> >           % ./foo                     # Run 'foo.pl' inside 'foo'
> >           % mv foo bar; ./bar         # Run 'bar.pl' inside 'foo'
> >
> >Is it possible to run 'bar.pl' from 'foo' without renaming 'foo' to 'bar'?
> >E.g. by passing special commandline option, or setting some special 
> >environment
> >variable?
> >
> >Or where is the place (file and subroutine names) I can hack PAR to add 
> >such
> >ability?
> >--
> > Best regards,
> >  -Vlad
> 
> 
> -- 
> _____________________________________________________________________________
> Bret Aarden, Ph.D. 1227 Jackson St Apt 414, Cincinnati OH 45202  
> 513/404-7444

Reply via email to