Scrat has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm using a java class in my perl script to encode zip files in a certain directory. Currently I'm defining the classes and relevant paths in a config file (Config-Tiny) and executing it using the "system" command. Here is some code to give you an idea:

#!/usr/bin/perl use strict; use warnings; use Config::Tiny; my $debug = 0; my $Configfile = "config.conf"; my $outputdir = "C:\\Outputdir"; my $Config = Config::Tiny->new(); $Config = Config::Tiny->read( $Configfile ); my $zipdir = $Config->{Config}->{Zip_Out}; my $somedir = $Config->{Config}->{Somedir_Path}; my $parser = $Config->{Config}->{Parser_Path}; my $xercesimpl = $Config->{Config}->{xercesImpl_Path}; my $encode = $Config->{Config}->{Encode_Command}; my $name = $Config->{Config}->{Name}; my $destination = $Config->{Config}->{Destination}; if (opendir (ZIPDIR, "$zipdir") ) { foreach my $zippedgif(readdir(ZIPDIR) ) { next if $zippedgif =~ /^\./; system("java -cp \"$somedir;$parser;$xercesimpl\" $enco +de \"$zipdir\\$zippedgif\" \"$outputdir\\$name\" $destination"); if ($debug) { print "DEBUG \nResult: $?\n" }; sleep 3; } } else { print "Error opening $zipdir: $!\n"; } closedir (ZIPDIR);

Is there an easier way to accomplish this in Perl rather than using the "system" or "backticks" commands or a config file?

Thanks

2006-04-20 Retitled by g0n, as per Monastery guidelines
Original title: 'Java Question'

Replies are listed 'Best First'.
Re: Better way to run a java class than calling system()?"
by mkirank (Chaplain) on Apr 19, 2006 at 09:39 UTC
Re: Better way to run a java class than calling system()?"
by chromatic (Archbishop) on Apr 19, 2006 at 17:53 UTC

    That depends on what the Java program does. What does it do?

      Well, it seems that it has something to do with "encoding zip files in a certain directory". So I'd point the OP to Archive::Zip.