I'm having trouble getting my (first-ever real-world) Perl script to run as
successfully on a Unix server as it does on my own Win98 system.
Script abc0.pl extracts and re-formats information from source file raw.txt,
creating first an intermediate file (out1.txt) and then a final output file,
out.txt.
It compiles without a problem and gives intended results on my Win98 system
at home. I'm using Perl 5.005_03, ActiveState build 522.
I then FTP the files to a server running Apache and Perl 5.005_02 "built for
rhapsody." The server is actually a Mac OS X server. I telnet
to that server and type:
bash-2.02$perl abc0.pl
I get an error message reading:
on #! line at abc0.pl line 1. (Note that the screen prints a single
wordspace before "on #!....")
The night before I had FTP'd a similar Perl script (try.pl -- not shown) and
a larger text input file to the same server. The script below, abc0.pl, is
exactly the same as that earlier script except I stripped out all the
comments. When I called perl try.pl, I got a different error message:
syntax error at try.pl line 68, near "format MEDHXREPORT ="
Execution of try.pl aborted due to compilation errors.
In each case I tried several variations on the Perl script which approach
the problem from different angles but produce the same desired results.
Though I got different error messages last night and tonight, on each night
I got the same error message on all variants of the script/source file
combination.
Can anyone suggest why scripts which compile and execute as desired using
ActiveState Perl are not working when I try them out on this Linux/Perl
server?
Thank you very much. Here are the script and source file I've been testing.
Jim Keenan, Brooklyn, NY
################################################################
#abc0.pl
################################################################
#!/usr/bin/perl -w
use strict;
my ($in);
my @scrips = ();
my ($med, $freq, $order, $strtdt, $md, $dose, $type, $stpdt);
open (IN,"raw.txt") || die "cannot open raw.txt for reading: $!";
open (OUT,">out1.txt") || die "cannot create out1.txt: $!";
while (<IN>) {
s/^\*+$/----------/g;
if ($_ =~ m/\bFREQ:|^DOCTOR:|^-+$/) {
print OUT $_;
}
}
close (IN) || die "can't close raw.txt:$!";
close (OUT) || die "can't close out1.txt:$!";
open (IN,"out1.txt") || die "cannot open out1.txt for reading: $!";
open(MEDHXREPORT, ">out.txt") || die "cannot create out.txt: $!";
my $old = select MEDHXREPORT;
$= = 51;
select $old;
while (<IN>) {
if (/(.*)^-+$/) {
$in .= $1;
} else {
$in .= $_;
}
}
$in =~ s/(.*)\n(DOCTOR.*)/$1 $2/g;
@scrips = split /\n/, $in;
foreach my $el (@scrips) {
$el =~
/(^.+\b[.,\/?;:%*&\(\)\[\]]?)\s+FREQ:\s(.+)\b\s+ORDER\s#\s+(\d+)\s+STARTED\s
{3}((\d\d\/){2}(\d){4})\s+DOCTOR:\s(.+)\s+DOSE:\s(.+)\s+TYPE\s+(\w+)\s+STOPP
ED\s{3}((\d\d\/){2}(\d){4})/o;
$med = $1;
$freq = $2;
$order = $3;
$strtdt = $4;
$md = $7;
$dose = $8;
$type = $9;
$stpdt = $10;
write (MEDHXREPORT);
}
close (IN) || die "can't close out1.txt:$!";
close (MEDHXREPORT) || die "can't close out.txt:$!";
format MEDHXREPORT =
@<<<<<<<<< @<<<<<<<<< @>>> @<<<<<<<<<<<<<<<<<<<<< @<<<<<
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<
$strtdt, $stpdt, $order, $md, $type, $med,
$dose, $freq
.
format MEDHXREPORT_TOP =
Page @<<<
$%
STARTED STOPPED NO. DOCTOR TYPE GENERIC
DOSE FREQUENCY
========== ========== ==== ====================== ======
============================== ==================== =========
.
################################################################
#raw.txt
################################################################
NEW YORK, N.Y. 98765-6098 POLKA DOT
PENICILLIN *SEIZURES
============================================================================
======================================================
============================================================================
======================================================
STATUS DATE: 01/01/1993 STATUS: INPATIENT LEGAL DATE: 03/01/1993
LEGAL STATUS: HOSP VOL
W/U DATE : 12/19/1996 W/U : 999 DIAG DATE : 01/01/1993
DIAGNOSIS : 999.99 999.98
*********************************************************************
ASPIRIN CALCIONIC FREQ: TID
ORDER # 135 STARTED 03/11/1997
DOCTOR: TOMLIN DOSE: 600 MG
TYPE SCH STOPPED 04/08/1997
----------------------------------------------------------------------------
------------------------------------------------------
SINFONIETTA MAGARITA FREQ: BID
ORDER # 136 STARTED 03/11/1997
DOCTOR: TOMLIN DOSE: 1 MG
TYPE SCH STOPPED 04/08/1997
----------------------------------------------------------------------------
------------------------------------------------------
PENTAPENTAMET FREQ: QD
ORDER # 137 STARTED 03/11/1997
DOCTOR: TOMLIN DOSE: 1
TYPE SCH STOPPED 04/08/1997
----------------------------------------------------------------------------
------------------------------------------------------
****************************************************************************
****
################################################################
#END OF EXAMPLE
################################################################
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]