Perl

by admin

Execute Java from Perl

my $cmdline = $JavaExe;

$cmdline .= " -ms".$MinHeapSize."M" if $MinHeapSize;
$cmdline .= " -mx".$MaxHeapSize."M" if $MaxHeapSize;
$cmdline .= " -jar " . EXECUTABLE_PATH . $executable .
" -m " . $h->{mode} .
" -cf " . $contextpath .
" -x " . $h->{xmlpath};
$cmdline .= " -cm " . $h->{mode} if $h->{mode};
$cmdline .= " -pm " . $h->{projmode} if $h->{projmode};
if ($h->{xmloutdir} || $XmlOutDir)
{ $cmdline .= " -xmloutdir " . ($h->{xmloutdir} || $XmlOutDir) }
}
$cmdline .= " -verbose " if $Verbose;
$cmdline .= " 1>$stdout 2>$stderr";
exec($cmdline)
 

Executin PERL within another PERL

system ("/usr/bin/perl","../response.pl", "-e=$Mode", "-admin=$admin");
 

Perl Threads & Fork example

Cause a process to become a daemon

Perl Loop

umask 002

ulimit -c unlimited

stdout

stderror

$cmdline .= " 1>$stdout 2>$stderr";

How should I call a Perl Script in Java?

You can use Runtime.getRuntime().exec() or use the Process API. The Process API allows you to get the output of the script, so you can have both communicate.

See: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Process.html

exitValue() and getInputStream() seems to be what you need.

Use XML-RPC to call Perl routines from your Java code

References:

http://perlbuzz.com/

Video Tutorial:

http://my.safaribooksonline.com/video/programming/perl/9780133036282

2008 Microsoft Scripting Games

PERL Frameworks:

Using Squatting with reverse proxy (Apache)

Squatting

http://stackoverflow.com/questions/799968/whats-the-difference-between-perls-backticks-system-and-exec


http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/

 

#!/usr/bin/perl

print "content-type: text/html \n\n";

# DEFINE A HASH
%coins = ( "Quarter" , 25,
           "Dime" ,    10,
           "Nickel",    5 );
           
# LOOP THROUGH IT
while (($key, $value) = each(%coins)){
     print $key.", ".$value."<br />";
}

Perl Regular Expression

can-a-hash-have-duplicate-keys-or-values:  can have duplicate values but not keys.

Perl referenceshttp://perldoc.perl.org/perlref.html

iterate-through-array-of-hashes-in-a-hash-in-perl

perl-complex-data-structures

how-to-get-hashes-out-of-arrays-in-perl

populate-hash-of-hashes-in-perl

 

Arrays of Hashes - Programming Perl Third Edition

how-can-i-check-if-a-file-exists-in-perl

perl-subroutine-reference

perlstrings - nice descption

String Replacement

Printing a Hash

are-quotes-around-hash-keys-a-good-practice-in-perl

split string into hash

removing-quotes-from-string

perl_hashes

perlarrays

perl Array

Perl Regular Expressions

OO Perl

Perl MongoDB Sample Queries

Perl MongoDB Distinct Query

cpan force install

storage-format-of-date-in-mongodb

convert-between-datetime-formats-using-perl

how-to-parse-a-string-into-a-datetime-object-in-perl

perl-how-to-convert-a-string-to-datetime

perl mongo queries

perl-running-multiple-processes-in-a-single-script

Perl MongoDB driver only able to insert 64 bit integers

Couldn't open encmap utf8.enc:No such file or directory at /usr/lib64/perl5/XML/Parser.pm line 187

Solution: 

<?xml version="1.0" encoding="UTF8" ?>

<?xml version="1.0" encoding="UTF-8" ?> //correct format