jdcotter has asked for the wisdom of the Perl Monks concerning the following question:

Simple question: How do I print the comment character (#) with a write statement using formats? Obviously perl thinks a # in the first column is a comment. Can you escape it? I can print it out if it's the second character but the output file looks kinda dumb. I just want to add some static text comments at the top via the STDOUT_TOP
  • Comment on printing comments with write and format

Replies are listed 'Best First'.
Re: printing comments with write and format
by Fastolfe (Vicar) on Sep 26, 2000 at 23:13 UTC
    I'm not sure how to put a pound sign in the format directly, but you can just put it as your first "field" in the format:
    format Comment = @ @<<<<<<<<<<<<<<<<<<<<<<<<< "#", "This line is a comment." .
Re: printing comments with write and format
by elwarren (Priest) on Sep 27, 2000 at 17:36 UTC
    Couldn't you stuff it into a variable and then just print the variable?