Sponsored Content
Top Forums Programming Perl script to create latex template. Post 302566767 by veerubiji on Friday 21st of October 2011 05:24:12 AM
Old 10-21-2011
Hi, I tried to run this sript but it gives error like pdflatex is not recognized by an internal or external command. operable program or batch file. I installed MikTex but I dnt know how to overcome this error .
Code:
#!/usr/bin/env perl

use strict;
use warnings;

use XML::Fast;
use Template;

my $xml = <<'XML';
 <student>
      <number>24</number>
      <education>bachelors</education>
      <specialization>computers </specialization>
     -<address>
         <house_number="128"/>
         <street name="xxxx"/>
           <proddutoor/>
      <address/>
     -<details>
          <name="clar"/>
          <age="20"/>
         <sex="m"/>
       </details>
</student>
 <student>
      <number>23</number>
      <education>ph.d.</education>
      <specialization>physics </specialization>
     -<address>
         <house_number="128"/>
         <street name="xxxx"/>
           <proddutoor/>
      <address/>
     -<details>
          <name="joel"/>
          <age="20"/>
         <sex="m"/>
       </details>
</student>
XML
my $xml_hash = xml2hash $xml;

my $template = Template->new();

my $filename = 'output.tex';

#I think the following is a holdover from a previous version
#as I cannot check right now, I will leave as a comment:
#open my $fh, '>', $filename;

$template->process(\*DATA, $xml_hash, $filename)
    || die "Template process failed: ", $template->error(), "\n";

system( "pdflatex $filename" );

__DATA__
\documentclass{article}

\title{Roster}
\author{pavani}

\begin{document}
\maketitle

[% FOREACH st IN student %]
Student [% st.number %] is a [% st.specialization %] [% st.degree %] student.

[% END %]

\end{document}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create users from template

Create users from template file (0 Replies)
Discussion started by: rijeshpp
0 Replies

2. Infrastructure Monitoring

Zabbix Template and PERL Script for Monitoring Apache2

Hello, Kindly find attached a copy of the Zabbix template and PERL script we are using to monitor our Apache2 server. Here are the entries for zabbix_agentd.conf UserParameter=apache2.total_accesses,/etc/zabbix/zabbix_apache2.pl|cut -f1 -d":"... (4 Replies)
Discussion started by: Neo
4 Replies

3. Programming

need help in perl template toolkit module.

Hi how can I read this information using template toolkit $var1= { 'STC'=> }; I am not able to get this type of complex data , Remaining everything I solved and I am getting output as I want but this problem suffers me.please help me. (0 Replies)
Discussion started by: veerubiji
0 Replies

4. Programming

perl script to create hash.

Hi, I have the xml file file this, perl script to create hash<p> <university> <name>svu</name> <location>ravru</location> <branch> <electronics> <student name="xxx" number="12"> <semester number="1"subjects="7" rank="2"/> </student> <student name="xxx"... (1 Reply)
Discussion started by: veerubiji
1 Replies

5. Shell Programming and Scripting

Script to create EVIM template with SAS extension

I write lots of SAS programs and would like to create a script that allows me to have a template each time I create a new program file. Specs: I use EVIM for my editor. I run SAS in batch mode. We use RedHat 6. I don't use c shell. I want a script that will do the following: >... (3 Replies)
Discussion started by: starbecks
3 Replies

6. Shell Programming and Scripting

[Solved] Remove LaTex Tag with perl

Hi, i am trying to remove all LaTex tags (\index{text} from a big input file, using perl. My current approach which does not work is the following. perl -ne '$/=undef; s/\\index\{*?\}//g; print' < $CWD/$OUTPUT.txt > tmp.txt But the tags still remain in the text. Can somebody tell my what I... (2 Replies)
Discussion started by: mortl
2 Replies

7. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

8. Programming

Perl script to create football formation

I need help to create varieties of football formation. The available positions are: GK SW DR DC DL WBR DM WBL MR MC ML AMR AMC AML ST But the conditions are: a. the maximum number in 1 formation: GK is 1 SW is 1 (1 Reply)
Discussion started by: Tzeronone
1 Replies

9. Red Hat

Create an unconfigured VMware host from a template that is set to do firstboot --reconfig

I have an Oracle Linux 7.1 vsphere host built. It's be preconfigured with our security configurations. What I would like to do is unconfigure this host. Then set the host to do firstboot --reconfigure. how do I do that using /etc/sysconfig/firstboot? I've tried setting ... (10 Replies)
Discussion started by: os2mac
10 Replies

10. Shell Programming and Scripting

Bash/awk and for loop to create a template

Source File: google.cz http://czechrepublic.google.com/ http://czechrepublic.google.cz http://czechrepublic.google.com/ http://brno.google.cz http://brno.google.com/ Fail Code root@arisvm ~/g] $ cat trya rm -f ss for i in a.txt do #b=`cat $i|awk '{print $1}'` #c=`cat $i|awk '{print... (4 Replies)
Discussion started by: invinzin21
4 Replies
Template::Modules(3pm)					User Contributed Perl Documentation				    Template::Modules(3pm)

NAME
Template::Modules - Template Toolkit Modules Template Toolkit Modules This documentation provides an overview of the different modules that comprise the Template Toolkit. Template The Template module is the front-end to the Template Toolkit for Perl programmers. use Template; my $tt = Template->new(); $tt->process('hello.html', message => 'Hello World'); Template::Base The Template::Base module implements a base class from which the other Template Toolkit modules are derived. It implements common functionality for creating objects, error reporting, debugging, and so on. Template::Config The Template::Config module defines the configuration of the Template Toolkit for your system. It is an example of a factory module which is responsible for instantiating the various other modules used in the Template Toolkit. For example, the Template::Config module defines the $STASH package variable which indicates which version of the Template::Stash you are using by default. If you elected to use the faster XS stash when you installed the Template Toolkit, then this will be set as: $STASH = 'Template::Stash::XS'; Otherwise you'll get the regular Perl stash: $STASH = 'Template::Stash'; This approach means that other parts of the Template Toolkit don't have to worry about which stash you're using. They just ask the Template::Config module to create a stash of the right kind. Template::Constants The Template::Constants defines a number of constants that are used by the Template Toolkit. For example, the ":chomp" tagset defines the "CHOMP_???" constants that can be used with the "PRE_CHOMP" and "POST_CHOMP" configuration options. use Template::Constants ':chomp'; my $tt = Template->new({ PRE_CHOMP => CHOMP_COLLAPSE, }); Template::Context The Template::Context module defines a runtime context in which templates are processed. A context keeps track of all the templates, variables, plugins, and other resources that are available (either directly or through delegate objects) and provides methods to fetch, store, and perform various operations on them. Template::Document The Template::Document module implements a compiled template document object. This is generated by the Template::Parser module. Template::Exception The Template::Exception module implements an exception object which is used for runtime error reporting. Template::Filters The Template::Filters module implements a filter provider. It includes the core collection of filters that can be used via the "FILTER" directive. Template::Iterator The Template::Iterator module implements a data iterator which steps through each item in a list in turn. It is used by the "FOREACH" directive. Within a "FOREACH" block, the "loop" variable always references the current iterator object. [% FOREACH item IN list; IF loop.first; # first item in loop ELSIF loop.last; # last item in loop ELSE; # any other item in loop END; END %] Template::Namespace::Constants The Template::Namespace::Constants module is used internally to represent constants. These can be resolved immediately at the point that a template is compiled. Template::Parser The Template::Parser module is used to parse a source template and turn it into Perl code which can be executed. Template::Plugin The Template::Plugin module is a base class for Template Toolkit plugins that can be loaded on demand from within a template using the "USE" directive. Template::Plugins The Template::Plugins module is the plugins provider. It loads and prepares plugins as and when they are requested from within a template. Template::Provider The Template::Provider module is responsible for loading, compiling and caching templates. Template::Service The Template::Service module implements a service layer that sits just behind the Template module, and just in front of a Template::Context. It handles each request to process a template (forwarded from the Template module). It adds any headers and/or footers (specified via the "PRE_PROCESS" and "POST_PROCESS" options), applies any wrapper (the "WRAPPER" option) and catches any errors returned (the "ERRORS" option). Template::Stash The Template::Stash module is used to fetch and store template variables. It implements all of the magic associated with the dot operator. Template::Stash::XS The Template::Stash::XS module is a high-speed implementation of Template::Stash written in C. Template::Test The Template::Test module is used to automate the Template Toolkit test scripts. perl v5.14.2 2011-12-20 Template::Modules(3pm)
All times are GMT -4. The time now is 09:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy