Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:38:22+00:00 2026-06-17T10:38:22+00:00

I am trying to autogenerate reports based from statistics acquired from our database. I

  • 0

enter image description hereI am trying to autogenerate reports based from statistics acquired from our database. I use perl to communicate with the database and store the interesting variables as scalars/arrays etc. I would then like to create a latex file before using pdflatex. However, I am having some issues trying to passenter image description here scalar values into the pdf. For example, please see my code below and the output

#!/usr/bin/perl
#
#
# Description: Write a monthly report from the database using latex
#    
# Parameters:
#
# History: 
#
# CVS ID: $Date: 2012/03/01 16:13:03 $ $Revision: 1.1 $
########################################################################

#Add library
use lib "$ENV{HOME}/perllib";

#Call modules
use DBI;                     # Postgres communication functions
use File::Temp qw/tempfile/;
use File::Copy;
use Cwd;

my $date_start = '01/12/12';
my $date_stop  = '31/12/12';


%hash=("01"=>"Jan","02"=>"Feb","03"=>"Mar","04"=>"Apr","05"=>"May","06"=>"Jun","07"=>"Jul","08"=>"Aug","09"=>"Sep","10"=>"Oct","11"=>"Nov","12"=>"Dec");
$date_start=~/([0-9]{2})\/([0-9]{2})\/([0-9]{2}).*/;
my $date_string = "$hash{$2}$3";
my $report_name = "$date_string"."_monthly_report.pdf";



#Pragmas

use warnings;
no warnings "uninitialized";  # Don't warn about unitialized variables#
use strict 'vars';          # Force all variables to have defined scope

my $repdir = "/home/nm/Desktop/";
my ($fh, $filename) = tempfile( SUFFIX => '.tex', DIR => $repdir);

# LaTeX Header information
print $fh <<'END';
\documentclass{article}
\usepackage{underscore}
\usepackage{fullpage}
\usepackage{multicol}
\usepackage[margin=0.5in]{geometry}
\usepackage{graphicx}
\usepackage{array}

\newenvironment{nstabbing}
  {\setlength{\topsep}{0pt}%
   \setlength{\partopsep}{0pt}%
   \tabbing}
  {\endtabbing}

\begin{document}


\begin{center}
\LARGE \bf MONTHLY SUMMARY
\end{center}


END

my $blank = " ";
# Body of LaTeX document
print $fh <<END;
This report details clinical and imaging statistics from $date_start to $date_stop

END
print $fh <<'END';
This report details clinical and imaging statistics from $date_start to $date_stop


\large \bf Clinical Statistics

\normalsize \rm 

\begin{table}[h]
\centering
\begin{tabular}{cccc} 
\hline
Task & AR & DB & GM \\
Cannulation & 1 & 2 & 3 \\
\hline
\end{tabular}
\end{table}

END

# Closing of LaTeX document
print $fh <<'END';
\end{document}
END

# Run LaTeX compiler to generate PDF
system('pdflatex -output-directory ' . $repdir . ' ' . $filename);
my $file_prefix = substr($filename, 0, -4);

#remove aux, log and tex files
my $auxfile = $file_prefix . ".aux";
my $logfile = $file_prefix . ".log";
my $pdffile = $file_prefix . ".pdf";

system('rm ' . $auxfile . ' ' .  $logfile . ' ' . $filename);
$filename="$repdir$report_name";
move($pdffile,$filename);

system('acroread ' . $filename);

Why does

print $fh <<END;
This report details clinical and imaging statistics from $date_start to $date_stop
END

give the correct output, while the following does not?

print $fh <<'END';
This report details clinical and imaging statistics from $date_start to $date_stop
END

I tried using the former to create the table on display but I could not get it in a nice format, e.g. it would create an extra column and place cannulation beside GM. Also when using the former I had to place an extra / before latex keywords, eg //bf rather than /bf whereas in the latter (‘END’) I don’t need to.

Ideally I’d prefer to use ‘END’ as my tables and latex formatting work as expected. However, I am unable to pass scalar and array values. How can I manage this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:38:23+00:00Added an answer on June 17, 2026 at 10:38 am

    The single quotes around 'END' mean that your here document is treated like a single-quoted string: no variables are interpolated within it.

    The default is to treat as a double quoted string, which is why your first example works. You can also use double quotes to explicitly specify that you want it to be like a double quoted string: <<"END"; (This is like the default behavior, but perhaps clearer).

    An inevitable consequence of using an interpolating (double quoted) string is that you have to escape things like backslashes–backslashes have a special meaning within this kind of string. You really have to pick one or the other: a string that interpolates variables and requires escaping, or a string that does not interpolate and does not require escaping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a program which will pseudorandomly autogenerate (based on a seed
I'm trying to create an html table from database records. I want the table
I am trying to learn database unit testing from ndbunit tutorial. All is going
I'm trying to put my database scripts into a VS Database project (I haven't
Im trying to use ASP.NET login controls, in a ASP.NET MVC project and i
I'm trying everything I can to get phpdocumentor to allow me to use the
While trying to use Maven for building Android projects I recognized that the maven-android-plugin
I'm currently trying to create a Python script that will autogenerate space-delimited arithmetic expressions
I am currently trying to populate a development database on a project with a
I'm trying to figure out how to auto generate/populate a column in excel based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.