NAME

rdbeval - compute data field values using Perl expressions


SYNOPSIS

rdbeval [options] [expressions]


OPTIONS

Options may be abbreviated. Options which take values may be separated from the values by white space or a `=' character.

--file file
Read expressions from file.

--require file
require (in the Perl sense) the file.

--help
Print this help information.

-x
Print out the Perl script which will be eval'd.


DESCRIPTION

rdbeval reads an rdb table from the standard input stream and writes a modified version to the standard output stream. It modifies columns via user-supplied Perl expressions, which are given access to the data via Perl variables with the same names as the column names. Column names are translated into legal Perl variable names by changing all non-legal characters to the underline character. (Legal characters are the alphanumeric and underline characters.)

For example, if the rdb table has columns Name, Address, pumpkin, rdbeval creates the Perl variables $Name, $Address, $pumpkin. These may be manipulated directly:

   rdbeval < snack.rdb '$Name =~ s/(Dr|Mr|Ms)\.\s*//' '$pumpkin *=2'

Expressions passed to rdbeval must be correct Perl expressions. Multiple expressions may be given as a single argument to rdbeval, separated by semi-colons (as in any Perl program). They may also be passed as separate arguments to rdbeval, in which case they need not end in a semi-colon.

Expressions may also be stored in files, and are specified on the command line as -f filename. Expressions in files may appear anywhere on the command line. Expressions are evaluated in the order that they appear on the command line.

To gain access to user defined functions, use the --require option. The specified files will be required by Perl (and thus must meet all of Perl's requirements for doing so). For example, say funcs.pl looks like this:

  sub dist 
  {
    my ( $x0, $y0, $x, $y ) = @_ ;
    sqrt( ($x-$x0)**2 + ($y-$y0) );
  }
  1;

To calculate the distance from the origin using rdbeval:

  rdbeval --require funcs.pl '$dist = dist(0,0,$x,$y)'


AUTHOR

Diab Jerius ( djerius@cfa.harvard.edu )