Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
XP is just a number
 
PerlMonks  

Better way to run a java class than calling system()?"

by Scrat (Monk)
on Apr 19, 2006 at 05:33 UTC ( [id://544301]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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 05:39 UTC
Re: Better way to run a java class than calling system()?"
by chromatic (Archbishop) on Apr 19, 2006 at 13: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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://544301]
Approved by AcidHawk
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.