PERL

This section describes using the PERL Corda® Embedder for those that use PERL to deliver Web content. Embedding a Corda image into a PERL script can be broken down into the following steps:

The example code at the end of this section shows how to embed a Corda image in PERL.

Note: This documentation assumes that you are familiar with PERL.

Including the Library

Before including the Corda Embedder library into a PERL script, make sure that <product_root>\Server\dev_tools\embedder\perl \CordaEmbedder.pm is accessible to the PERL scripts.The easiest way to do this is to copy it to the same folder as the scripts that use Corda Embedder. Alternatively, copy CordaEmbedder.pm to the folder where PERL keeps its modules (e.g., C:\PERL\lib, /usr/lib/perl/5.6.0).

To include the Corda Embedder library in a PERL script, include the following line at the beginning of the script.

use CordaEmbedder;

This instructs the PERL compiler to load the CordaEmbedder module.

Instantiating a Corda Embedder Object

To instantiate a Corda Embedder object, use code similar to the following:

$myImage = CordaEmbedder->new();

Syntax Notes

Most of the example code in this Reference assumes that you are using the Java* Corda Embedder. Thus, you must convert the example code syntax for use with PERL. When doing this, consider the following:

For example, consider the following command in Java:

myImage.imageTemplate = "bar.itxml";

The equivalent code in PERL is as follows:

$myImage->imageTemplate("bar.itxml");

The following Corda Embedder methods are unavailable with PERL:

Setting the Server Information

Corda Embedder needs to know two Corda Server™ addresses: the address that the Web client uses to access Corda Server (externalServerAddress), and the address that Corda Embedder uses to access Corda Server (internalCommPortAddress). For more information about determining these addresses, see Identifying Server Addresses.

For example, if Corda Embedder communicates with Corda Server at 10.0.1.1:2002, and Web clients request images from http://<server_address>:2001, include the following in the code that generates the Corda image:

$myImage->externalServerAddress("http://<server_address>:2001");

$myImage->internalCommPortAddress("10.0.1.1:2002");

Specifying Image Information

After specifying server address information, give Corda Embedder some information about the Corda image you want to embed.

There are numerous Corda Embedder commands to specify image information, which are consistent in all Web application environments (with the exception of several syntax differences, as previously explained in Syntax Notes). Thus, it is unnecessary to discuss each of these commands individually at this time.

The table below provides links to more information about Corda image features and components:

Topic

Where To Go

Annotations

Data Annotations in the Corda Builder™ User Guide

Content Delivery / Presentation Control

Image Deployment Issues and Descriptive Text Settings

Data

Connecting to Data Files and Connecting to Databases

Drilldown

Building Drilldown

Graph or Map Customization

Dynamically Customizing Graphs and Maps

Image Size & Format

Changing the Image Format and Changing Image Size

Writing the Image to a Web Page

When you are ready to write the embedding HTML to the Web page, output the getEmbeddingHTML() method using the print statement. For example:

print $myImage->getEmbeddingHTML();

Complete Example Code

The sample code below demonstrates embedding a Corda image with PERL.

Note: To produce an example map instead of a graph, replace examples\bar.itxml with examples\map\australia_combo.itxml in the code designating the Image Template file.

Embedding a Corda Image with PERL

#!/usr/bin/perl -w

 

use CordaEmbedder;

 

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

print "<html>\n";

print "<head>\n";

print "<title>My First Embedded Image</title>\n";

print "</head>\n";

print "<body>\n";

print "<h1>This is your image</h1>\n";

print "<hr />";

 

# insert Corda image here

 

$myImage = CordaEmbedder->new();

$myImage->externalServerAddress("<server_address>:2001");

$myImage->internalCommPortAddress("localhost:2002");

$myImage->imageTemplate ("image_templates\examples\bar.itxml");

$myImage->width(600);

$myImage->height(400);

$myImage->pcScript("title.setText(Hello World)");

 

print $myImage->getEmbeddingHTML();

 

print "\n<hr />\n";

print "<p>If you see an image above, congratulations.  You have successfully embedded your first image.</p>\n";

print "</body>\n";

print "</html>\n";