> Hi every one,
>   sorry for small mistake,so i modified and reposteing the question in reply. 
> actuvally I used perl getlogin to get username , I am getting but I don't how 
> to access this variable in template toolkit process please tell me
> 
> I have problem with getting username form windows system. I tried using 
> getlogin function in perl and printing it printing my user name , but my 
> problem is how can I access this username in template toolkit. I tried like 
> this

Hi veeru,

Clearly this question is very closely related to the one I answered for you on 
Stack Overflow yesterday.

You're passing all your data to your template via the $data object, and 
username is not in that. Exactly what is going on in your XML is not real 
clear, but would it be possible to add username to the XML::Simple structure? 
Then you would have it available in your template.

Otherwise, a quick and dirty solution is to create a different variable on the 
perl side that is a hashref containing both the XML and any other stuff you 
will need in the template.

my $template_vars = {
        xmldata => $data,
        username => $username,
};

<snip>
$template->process(\*DATA, $template_vars, $filename)

And tweak your template to match:

\issuedby{ [% username %] }

[% FOREACH comp IN xmldata.company %] 
... and so on.

Obviously since you're going to the trouble of building your XML structure, 
adding username and anything else you're going to need template-side into that 
would be more elegant.

Hope that helps.
_________________________________________________________
If you receive an email from the Health Department, saying that if you eat
tinned pork you will contract swine flu, delete it because it is spam.

Richard Thomas

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to