[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Having a problem with format



Some time around 9/17/97 1:51 AM CDT, D. Beverly wrote something about

>Some time around 9/16/97 11:13 PM CDT, WAMerrill@aol.com wrote something 
>about
>
>>format Something =
>>		        Test: @<<<<<<<< @||||| @>>>>>
>>		              $str,     $%,    '$' . int($num)
>>		    .
>
>     Well, if this is how your code looks in reality, the problem is 
>easily solved.  The terminating dot needs to be the first, last, and only 
>character on the line, preceded by nothing and followed only by a CR.  
>Spaces, tabs, comments, etc. will cause it to fail.
>
>     Try this and see if it doesn't solve your problem.


     Oops, I sent this before I was finished writing it -- continuing...

     In the field lines, whitespace is interpreted exactly as it appears. 
 In the value lines, whitespace is ignored and can be used to make your 
code more readable, as you've done in your example.  MacPerl interprets 
the existence of whitespace on the intended terminating line to mean that 
the line is actually a field line, and then is left looking for a 
terminator afterward that isn't there.  If for some odd reason you had a 
dot on a line by itself later in the program (such as perhaps another 
format's terminator), all code up to that point would be interpreted as 
part of the format.

     Try this instead:

format SOMETHING =
		        Test: @<<<<<<<< @||||| @>>>>>
		              $str,     $%,    '$' . int($num)
.
^--(all alone, at the start of the line)

     I usually put all my format declarations near the beginning of the 
file, since it's basically initialization of sorts.  If you put yours at 
the end of your file, be sure to add a CR after the terminating dot.  
Just like with a string terminator, this is necessary for correct 
interpretation by MacPerl.  But, unlike a string terminator, where you 
can include whitespace (that might exist to make your code more readable) 
like so:

     print <<'     END_';
     Stuff to print...
     END_

you can't do this with a format.

     Hope this helps.

Dave Beverly
webmaster@thecitizennews.com -- http://www.thecitizennews.com/
webmaster@henrynews.com -- http://www.henrynews.com/
Mac Manipulator
"I don't do windows!"

**
MacOS is an operating system; OS/2 is half an operating system; windoze 
is a shell; DOS is a boot partition virus... where do you want to go 
today?


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch