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'


In reply to Better way to run a java class than calling system()?" by Scrat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.