Hi, In my second reply where I included the entire two files, those are the same two files I ran on my server. I am at a loss why you get syntax errors and I don't. As I said I used the same command as you perl -c -e "use Cos::rxi" in the same folder as the rxi.pm file and the only errors I got were the global symbol errors. Thank you for your interest.
I am copying the same rxi.pm file below again.
#!/usr/bin/perl -w
=head1 NAME
use Cos::rxi
=head1 SYNOPIS
used to generate rxi files
=head1 DESCRIPTION
=head1 AUTHOR
=head1 COPYRIGHT
=head1 SEE ALSO
=cut
package Cos::rxi;
use strict;
#use warnings;
use Getopt::Std;
use DBI;
use Cos::Constants;
use Cos::Dbh;
use Math::Trig;
BEGIN {
use Exporter ();
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 1.00;
# if using RCS/CVS, this may be preferred
$VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf
+ "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
@ISA = qw(Exporter);
@EXPORT = qw(generate_rxi);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw();
}
use vars @EXPORT_OK;
########################################################
# create the rxi and oma files for an Innovations order
########################################################
sub generate_rxi {
my($dir, $aOrder) = @_;
my $orderId = $aOrder->{orders_pending_id};
my $userId = $aOrder->{user_id};
my $labId = $aOrder->{lab_id};
print "Processing Order # $orderId, lab: $labId, user: $userId\n";
my($base) = $dir.$aOrder->{field_acct_id}.'-'.$aOrder->{orders_pen
+ding_id}.'.';
open(FH, "> $base.rxi\0") or die "Can't create $base ($!)\n";
print FH "TRC " . $aOrder->{field_acct_id} . '-' . $aOrder->{order
+s_pending_id};
print FH "PTN " . $aOrder->{field_client_name};
if ($aOrder->{lens_Pair} == "1") {
print FH "LNS 0 1";
} elsif ($aOrder->{lens_Pair} == "2") {
print FH "LNS 1 0";
} else {
print FH "LNS 1 1";
}
print FH "LAS " . lensAlias($aOrder->{lens_OD_MaterCode},
$aOrder->{lens_OD_StyleCode},
$aOrder->{lens_OD_ColorCode},
$aOrder->{lens_OS_MaterCode},
$aOrder->{lens_OS_StyleCode},
$aOrder->{lens_OS_ColorCode});
+ #CREATE THE LENS ALIAS
print FH "DBL " . $aOrder->{fdDBL};
print FH "FSC 1"; # diameter orders
+ will send 6 and a UBS
my $frameDesc = rtrim($aOrder->{frame_desc});
if ($frameDesc =~ m/$\d/) {
print FH "FTP ". substr($frameDesc, length($frameDesc)-1, leng
+th($frameDesc));
} else{
print FH "FTP 0";
}
print FH "SPH " . $aOrder->{rx_OD_Sphere} . ' ' . $aOrder->{rx_OS
+_Sphere};
print_if(\*FH, 'CYL ', $aOrder->{rx_OD_Cylinder}, $aOrder->{rx_OS_
+Cylinder});
print_if(\*FH, 'AXS ', $aOrder->{rx_OD_Axis}, $aOrder->{rx_OS_Axis
+});
print_if(\*FH, 'ADD ', $aOrder->{rx_OD_Add}, $aOrder->{rx_OS_Add})
+;
print_if(\*FH, 'FPD ', $aOrder->{rx_od_far}, $aOrder->{rx_os_far})
+;
print_if(\*FH, 'NPD ', $aOrder->{rx_od_near}, $aOrder->{rx_os_near
+});
print_if(\*FH, 'SHT ', $aOrder->{rx_OD_Seg_Height}, $aOrder->{rx_O
+S_Seg_Height});
print_if(\*FH, 'OCH ', $aOrder->{rx_OD_OC_Height}, $aOrder->{rx_OS
+_OC_Height});
print_if(\*FH, 'BCV ', $aOrder->{rx_OD_Special_Base_Curve}, $aOrde
+r->{rx_OS_Special_Base_Curve});
if ( length($aOrder->{rx_OD_Special_Thickness}) > 0
|| length($aOrder->{rx_OS_Special_Thickness}) > 0) {
my $temp1 = length($aOrder->{rx_OD_Special_Thickness}) > 0
? $aOrder->{rx_OD_Special_Thicknes
+s}
: '0.00';
my $temp2 = length($aOrder->{rx_OS_Special_Thickness}) > 0
? $aOrder->{rx_OS_Special_Thicknes
+s}
: '0.00';
if ($aOrder->{rx_OD_Thickness_Reference} == 'Edge') {
print FH 'EDG ' . $temp1 . ' ' . $temp2;
} else {
print FH 'CTH ' . $temp1 . ' ' . $temp2;
}
}
if (length($aOrder->{rx_OD_Prism_Diopters}) ne 0
|| length($aOrder->{rx_OS_Prism_Diopters}) ne 0) {
my @array1 = qw($aOrder->{rx_OD_Prism_Diopters}
$aOrder->{
+rx_OD_Prism}
$aOrder->{
+rx_OD_Prism_Angle_Val}
$aOrder->{
+rx_OD_Prism2_Diopters}
$aOrder->{
+rx_OD_Prism2});
my @array2 = qw($aOrder->{rx_OS_Prism_Diopters}
$aOrder->{
+rx_OS_Prism}
$aOrder->{
+rx_OS_Prism_Angle_Val}
$aOrder->{
+rx_OS_Prism2_Diopters}
$aOrder->{
+rx_OS_Prism2});
# if values are specified as Angles, convert them to direction
if ($array1[1] == 'Angle') {convertPrismData(0, \@array1);}
if ($array2[1] == 'Angle') {convertPrismData(1, \@array2);}
my $ODP1Val = $array1[0];
my $ODP1Dir = $array1[1];
my $ODP2Val = $array1[3];
my $ODP2Dir = $array1[4];
my $OSP1Val = $array2[0];
my $OSP1Dir = $array2[1];
my $OSP2Val = $array2[3];
my $OSP2Dir = $array2[4];
# Innovations only expresses prism as IN or UP
# reverse anthing that is OUT or DOWN
if ($ODP1Dir == "OUT" || $ODP1Dir == "DOWN") {
if (length($ODP1Val != 0) {$ODP1Val = '-' . $ODP1Val);}
if ($ODP1Dir == "OUT") {
$ODP1Dir = "IN");
} else {
$ODP1Dir = "UP");
}
}
if ($ODP2Dir == "OUT" || $ODP2Dir == "DOWN") {
if (length($ODP2Val != 0) {$ODP2Val = '-' . $ODP2Val);}
if ($ODP2Dir == "OUT") {
$ODP2Dir = "IN");
} else {
$ODP2Dir = "UP");
}
}
if ($OSP1Dir == "OUT" || $OSP1Dir == "DOWN") {
if (length($OSP1Val != 0) {$OSP1Val = '-' . $OSP1Val);}
if ($OSP1Dir == "OUT") {
$OSP1Dir = "IN");
} else {
$OSP1Dir = "UP");
}
}
if ($OSP2Dir == "OUT" || $OSP2Dir == "DOWN") {
if (length($OSP2Val != 0) {$OSP2Val = '-' . $OSP2Val);}
if ($OSP2Dir == "OUT") {
$OSP2Dir = "IN");
} else {
$OSP2Dir = "UP");
}
}
my $PIN_String;
my $PUP_String;
if (length($ODP1Val) > 0) {
if ($ODP1Dir == "IN") {
$PIN_String = $ODP1Val;
$PUP_String = (length($ODP2Val) > 0) ? $ODP2Val : " 0
+.00");
} else { #UP
$PUP_String = $ODP1Val;
$PIN_String = (length($ODP2Val) > 0) ? $ODP2Val : " 0
+.00");
}
} else {
$PIN_String = " 0.00";
$PUP_String = " 0.00";
}
if (length($OSP1Val) > 0) {
if ($OSP1Dir == "IN") {
$PIN_String .= (" " . $OSP1Val);
$PUP_String .= length($OSP2Val) > 0) ? (" " . $OSP2Va
+l) : " 0.00");
} else {
$PUP_String .= (" " . $OSP1Val);
$PIN_String .= (length($OSP2Val) > 0) ? (" " . $OSP2V
+al) : " 0.00");
}
} else {
$PIN_String .= " 0.00";
$PUP_String .= " 0.00";
}
print FH "PIN " . $PIN_String;
print FH "PUP " . $PUP_String;
}
if (length(trim($aOrder->{tr_Tinting})) > 0 ||
length(trim($aOrder->{tr_TintColor})) > 0 ||
length(trim($aOrder->{tr_TintPerCent})) > 0) {
print FH "SPT " . $aOrder->{tr_Tinting} . " " . $aOrder->{
+tr_TintColor} . " " . $aOrder->{tr_TintPerCent};
}
if (length(trim($aOrder->{tr_Coating})) > 0 ||
length(trim($aOrder->{tr_AntiReflective})) > 0) {
print FH "SPC " . $aOrder->{tr_Coating} . " " . $aOrder->{
+tr_AntiReflective};
}
if (length(trim($aOrder->{tr_Treatment})) > 0 ||
length(trim($aOrder->{tr_Other1})) > 0 ||
length(trim($aOrder->{tr_Other2})) > 0 ||
length(trim($aOrder->{tr_Other3})) > 0 ||
length(trim($aOrder->{tr_Other4})) > 0) {
print FH "SPX " . $aOrder->{tr_Treatment} . " " . $aOrder-
+>{tr_Other1}
. " " . $aOrder->{tr_Other2} . " " .
+$aOrder->{tr_Other3}
. " " . $aOrder->{tr_Other4};
}
print FH "$$$";
close(FH);
t_write($base.'oma', $aOrder);
return $base;
}
########################################################
# create the lens alias value
########################################################
sub lensAlias {
my($mcodeL, $scodeL, $ccodeL, $mcodeR, $scodeR, $ccodeR) = @_;
return lpad($mcodeL,3).lpad($scodeL,5).lpad($ccodeL,5).lpad($mcode
+R,3).lpad($scodeR,5).lpad($ccodeR,5).
', ' . lpad($mcodeL,3).lpad($scodeL,5).lpad($ccodeL,5).lpa
+d($mcodeR,3).lpad($scodeR,5).lpad($ccodeR,5);
}
########################################################
# print if there are values
########################################################
sub print_if {
my($FH, $orderKey, $odVal, $osVal) = @_;
if ($odVal == null) {$odVal = '0';}
if ($osVal == null) {$osVal = '0';}
if ($odVal > 0 || $osVal > 0) {
print $FH $orderKey . ' ' . $odVal . ' ' . $osVal;
}
}
########################################################
# convert prism angle to its vertical and horizontal components
########################################################
sub convertPrismData {
my($lr) = $_[0];
my($q2q3,$q1q4);
if ($lr == 0) { # OD setup
$q2q3 = "OUT";
$q1q4 = "IN";
} else { # OS setup
$q2q3 = "IN";
$q1q4 = "OUT";
}
my $vertical_component = round($_[1]->[0] * sin($_[1]->[2] * PI/18
+0.0) * 100.0) / 100.0;
my $horizontal_component = round($_[1]->[0] * cos($_[1]->[2] * PI/
+180.0) * 100.0) / 100.0;
$_[1]->[0] = abs($vertical_component);
$_[1]->[1] = (($vertical_component < 0) ? "DOWN" : "UP");
$_[1]->[3] = abs($horizontal_component);
$_[1]->[4] = (($horizontal_component < 0) ? $q2q3 : $q1q4);
return;
}
########################################################
# pad value with leading zeros
########################################################
sub lpad {
my($v, $pad) = @_;
return sprintf("%0${pad}d", $v);
}
########################################################
# write the trace into a file
########################################################
sub t_write {
my($file, $aOrder) = @_;
my($trace) = $aOrder->{trace_file_data};
if (!defined($trace) || length($trace) == 0) {
print "No trace file.\n";
return;
}
open(F, "> $file\0") or die "Can't create trace-file $file ($!)\n"
+;
print F $trace;
close(F);
print "Trace file: $file\n";
}
########################################################
|