Perl Scripting

This node allows you to execute arbitrary Perl script to create a new column or to replace an existing one.

The preface script is run once before the data from the input table is read. It can be used to define variables which will be available in the body script.

The body script is run for each row. The predefined variables $ROWKEY and $ROWINDEX give the key of the row and its index, respectively. To address certain input values use the predefined hash $column. For instance, the value of the column with name frequency can be obtained by $column{'frequency'}. When frequencies is a collection cell, $column{'frequencies'} is a reference to an array so that the first element of frequencies can be obtained by $column{'frequencies'}[0]. Note, that the character "'" in the column name must be escaped by "\'".

Beside the predefined hash $column there is an array called $column_names which holds column names (the keys of $column) in same order as in the input table.

The output of your script is the value of the last expression, or can be specified by the return statement. Please, return a reference to an array when the output is of collection type, or undef when the output should be a missing cell.

Options

Perl Script

Column List
The list contains the columns that are available in the input table. Double click any of the column names to insert the respective field in the body script. It will replace your current selection or simply insert at the current caret position.
Preface Script
Define global variables here. These variables are available during the execution of the body script and they are also modifiable.
Body Script
Enter your Perl code here (the entire source will be wrapped in a subroutine). The input is available by the predefined hash $column Its keys are the column names of the input table. The output is the value of the last expression, or can be defined by the return statement. Please, return a reference to an array when the output is of collection type, or undef when the output should be a missing cell.
Return type
Specify here the resulting type of your body script.
Array Return
If the result is an array (collection type), check this box. It will be represented by a KNIME collection cell.
Replace/Append
Specify here if you want the result to be put into a separate or existing column.
Automatically determine used columns
If checked only those columns referenced in the Body Script will be sent to Perl. This saves communication overhead but disables a dynamic access on the columns (by means of variables).
Send rows to Perl with chunk size
The input table is sent in chunks to Perl. Increase this value to minimize the impact of communication latencies. Decrease this value to save memory.

Perl Executable

Use custom perl executable
Enable this options and select a perl executable below if you do not want to use the standard executable.

Input Ports

Icon
Input table.

Output Ports

Icon
Input table with an additional calculated column or one column replaced.

Popular Predecessors

Views

This node has no views

Workflows

  • No workflows found

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.