Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: LaTeX Wizard

by linuxer (Curate)
on Sep 03, 2008 at 14:50 UTC ( [id://708774]=note: print w/replies, xml ) Need Help??


in reply to Re^2: LaTeX Wizard
in thread LaTeX Wizard

For printing multiple lines of static content (static that you don't have to check a condition if you want to print that), you can use HERE-documents.
Or you give a list of strings as arguments to that print (within this you can even check the conditions, if you must to):

# it interpolates variables print OUT <<"END_OF_PRINT"; Hello $world. many lines many lines END_OF_PRINT
print OUT "string1\n", "string2\n", "string3\n", ;

But all these solutions lead to CountZero's answer. Have you already considered his tip about using a templating system?

You create a template with all the static content you have.
In place of the non-static content you set up placeholders.
Inside your Perl-Code you load your template with the corresponding
template system and define the content for the placeholders.
Then you print the generated output.
The details are related to the template system you choose.

Additional point (not related to the templates):

If you open a file for writing, you should check that the open was successful:

open OUT, '>', $file or die "$file: open for writing failed: $!\n";

You should also check the success of all prints and the final close on that handle OUT.

print OUT "text bla bla\n" or die "$file: print failed: $!\n"; close OUT or die "$file: close failed: $!\n";

If you manage to reduce the number of prints these checks aren't too bad ;o)

Replies are listed 'Best First'.
Re^4: LaTeX Wizard
by milarepa (Beadle) on Sep 03, 2008 at 21:57 UTC
    Thank you linuxer for your tip, actually I just seen something similar on "Perl Best Practices" page 61. I will try to consider templates as well.

    Thanks for your help...!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://708774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-19 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found