Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thanks for the detail explanation !

From my tests with Text::Template, I saw that I had to name variables without the package component to catch syntax errors. Having read the docs (sorry, can't find exactly where) this became clearer.

There is no begin bloc in the loop that gives values to the glob variables Re: Text::Template and delayed use vars as in your last working example

eval ' package T; print "B: $x\n"; 1 ' or warn "B: $@";

This seems to be what happen in the module (version 1.47), around line 309 (the print line is mine):

sub fill_in { ... my $fi_progtext = "package $fi_eval_package; $fi_prepend;\n$fi_lcomment\n$fi_tex +t;"; ... print "eval on \n", $fi_progtext,"\n"; $fi_res = eval $fi_progtext;

Which prints

eval on package T; use strict;; #line 1 dokpe.tmpl $annee ; eval on package T; use strict;; #line 4 dokpe.tmpl "\t";
For a template file starting with
Plan de fermeture { $annee } Bibliothèque de la Faculté des Sciences (Dokpe) Motif{"\t"}

So to be sure I understand correctly: since I use eval during the script runtime, I do not need the begin block to assign a value to the glob. In my example above, the begin was needed because the print statement was run during the execution time. Is that correct ?

Thanks again

François


In reply to Re^2: Importing a variable into a package by frazap
in thread Importing a variable into a package by frazap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found