Re: [MacPerl-WebCGI] well split!!!
[email protected] Thu, 8 Mar 2001 00:54:43 +0900
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <v04011700b6cc067caef4@[61.115.108.64]> |
Ted:
see ==SAMPLE SCRIPT 1== for a possible solution to your original prob - the
sample __DATA__ should be tab separated - check it before you run it as
some mailers translate tabs to spaces, and don't leave '==SAMPLE SCRIPT1
==' mixed in with the data
>However, the following code generates an error Why?
>
> print <<ROW;
> <TR>
> <TD>$variable_name</TD>
> <TD>$description</TD>
> </TR>
> ROW
>}
The final 'ROW' must be flush against the right margin or Perl thinks it's
part of what you want to print:
running '==SAMPLE SCRIPT 2==' (using -w flag only) gets you a warning like
this:
"Can't find string terminator "ROW" anywhere before EOF"
running ==SAMPLE SCRIPT 3== gets you this (which do you find more useful at
understanding what went wrong?):
DESCRIPTION OF DIAGNOSTICS
These messages are classified as follows (listed in increasing order of
desperation):
(W) A warning (optional).
(D) A deprecation (optional).
(S) A severe warning (mandatory).
(F) A fatal error (trappable).
(P) An internal error you should never see (trappable).
(X) A very fatal error (nontrappable).
(A) An alien error message (not generated by Perl).
be captured by setting $SIG{__WARN__} to a reference to a routine that
will be called on each warning instead of printing it. See perlvar.
Trappable errors may be trapped using the eval operator. See
perlfunc/eval.
just as in a printf format. Note that some messages start with a %s!
The symbols "%-?@ sort before the letters, while [ and \ sort after.
# Can't find string terminator "ROW" anywhere before EOF.
File '<AppleEvent>'; Line 5 # (#1)
(F) Perl strings can stretch over multiple lines. This message means that
the closing delimiter was omitted. Because bracketed quotes count nesting
levels, the following is missing its final parenthesis:
print q(The character '(' starts a side comment.)
# Uncaught exception from user code:
# Can't find string terminator "ROW" anywhere before EOF.
File '<AppleEvent>'; Line 5
==SAMPLE SCRIPT 1==
#! perl -w
use strict;
use diagnostics-verbose;
my(@array_of_data,$data);
while (<DATA>) {
next if /^$/;
@array_of_data= split(/\t/);
print "<TR>\n";
for $data (@array_of_data){
print "<TD>$data</TD>";
}
print "\n</TR>\n";
}
__DATA__
database_id1 category1 variable_name1 price1 description1
item_number1
database_id2 category2 variable_name2 price2 description2
item_number2
database_id3 category3 variable_name3 price3 description3
item_number3
database_id4 category4 variable_name4 price4 description4
item_number4
==SAMPLE SCRIPT 1==
==SAMPLE SCRIPT 2==
#! perl -w
print <<ROW;
> <TR>
> <TD>$variable_name</TD>
> <TD>$description</TD>
> </TR>
ROW
==SAMPLE SCRIPT 2==
==SAMPLE SCRIPT 3==
#! perl -w
use diagnostics-verbose;
print <<ROW;
> <TR>
> <TD>$variable_name</TD>
> <TD>$description</TD>
> </TR>
ROW
==SAMPLE SCRIPT 3==
HTH
Robin