Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

next char ; syntax error in format

by neilwatson (Curate)
on Oct 17, 2009 at 00:43 UTC ( #801688=perlquestion: print w/ replies, xml ) Need Help??
neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting this error 'syntax error at ./todo.pl line 238, next char ;' Here is the code snippet. My perl is a bit rusty but this error is unfamiliar.
... 228 write $out; 229 } 230 close $out; 231 232 ########################## 233 # Formats 234 format PROJECT_TOP = 235 Project report for @* on (today) 236 --------------------------- 237 $PROJECT 238 . 239 240 format PROJECT = 241 @* @* @* @* @* 242 $DUE, $AT, $PRIORITY, $MSG, $CONTEXT 243 . 244 ...

Neil Watson
watson-wilson.ca

Comment on next char ; syntax error in format
Download Code
Replies are listed 'Best First'.
Re: next char ; syntax error in format
by biohisham (Priest) on Oct 17, 2009 at 13:44 UTC
    The error is that @* from the format for page header looks in the subsequent line for the scalar it can represent and finds nothing but a dashed line so a little permutation can solve that. Move $PROJECT over the dashed line.
    format PROJECT_TOP = Project report for @* on (today) $PROJECT --------------------------- .
    Why bichonfrise74 solution would not work, consider having added that line and see the output:
    format STDOUT_TOP = Project report for Mr. @* on (today) --------------------------- $PROJECT_HEAD . format STDOUT = @* @* @* @* @* $DUE, $AT, $PRIORITY, $MSG, $CONTEXT . my $PROJECT_HEAD="NeilWatson"; write;
    #OUTPUT Project report for Mr. on (today) --------------------------- $PROJECT_HEAD
    As you could see @* read the empty line and hence showed empty value for the title and this served to silence perl from complaining. Now consider the output from the following code snippet:
    format STDOUT_TOP = Project report for Mr.@* on (today) $PROJECT_HEAD --------------------------------- . format STDOUT = @* @* @* @* @* $DUE, $AT, $PRIORITY, $MSG, $CONTEXT . $PROJECT_HEAD="NeilWatson"; write;
    #OUTPUT: Project report for Mr.NeilWatson on (today) ---------------------------------
    It'll be better if you removed the line numbers from the code segment in future posts, that makes it easier to get down to work with eliminating the need for having to manually remove the line numbers.

    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.
Re: next char ; syntax error in format
by bichonfrise74 (Vicar) on Oct 17, 2009 at 03:17 UTC
    I'm not familiar with 'format', but it looks like if you add an empty line after line 235, then it would work. Try to check perlform. Please see below.
    #!/usr/bin/perl use warnings; use strict; my ($DUE, $AT, $PRIORITY, $MSG, $CONTEXT); format PROJECT_TOP = Project report for @* on (Today) --------------------------- $PROJECT . format PROJECT = @* @* @* @* @* $DUE, $AT, $PRIORITY, $MSG, $CONTEXT .
Re: next char ; syntax error in format
by Marshall (Prior) on Oct 17, 2009 at 13:22 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://801688]
Approved by ww
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-08-04 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (59 votes), past polls