[32805] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4069 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 4 03:09:43 2013

Date: Mon, 4 Nov 2013 00:09:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 4 Nov 2013     Volume: 11 Number: 4069

Today's topics:
    Re: Can this be combined into one statement? <rweikusat@mobileactivedefense.com>
    Re: Can this be combined into one statement? (Tim McDaniel)
    Re: Can this be combined into one statement? <derykus@gmail.com>
    Re: Can this be combined into one statement? <jblack@nospam.com>
    Re: Can this be combined into one statement? <rweikusat@mobileactivedefense.com>
        dir is open <gravitalsun@hotmail.foo>
    Re: dir is open <jurgenex@hotmail.com>
    Re: dir is open <ben@morrow.me.uk>
    Re: dir is open <bill@todbe.com>
    Re: dir is open <gravitalsun@hotmail.foo>
    Re: dir is open <rweikusat@mobileactivedefense.com>
    Re: dir is open <bill@todbe.com>
    Re: dir is open <derykus@gmail.com>
    Re: dir is open <ben@morrow.me.uk>
    Re: dir is open <derykus@gmail.com>
        PDF, Excel, LaTeX, and possibly R and sweave <cartercc@gmail.com>
    Re: PDF, Excel, LaTeX, and possibly R and sweave <john@castleamber.com>
    Re: PDF, Excel, LaTeX, and possibly R and sweave <cartercc@gmail.com>
    Re: PDF, Excel, LaTeX, and possibly R and sweave <ben@morrow.me.uk>
    Re: PDF, Excel, LaTeX, and possibly R and sweave <cartercc@gmail.com>
    Re: PDF, Excel, LaTeX, and possibly R and sweave <mvdwege@bors.avalon.lan>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 01 Nov 2013 21:34:10 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Can this be combined into one statement?
Message-Id: <871u2zbyct.fsf@sable.mobileactivedefense.com>

Charles DeRykus <derykus@gmail.com> writes:
> On 10/30/2013 11:29 AM, Ben Morrow wrote:
>>
>>>
>>> Why does /(\S+)\s*$/ have to backtrack over "the whole string" whereas
>>> /.*\s(\S+)/ does not?
>>> I'm sure I don't undertand regex backtracking...
>>
>> Consider a string like "foo bar baz ". For /\S+\s*$/ perl tries the
>> following sequence of matches:

[...]

> I thought a possessive quantifier would help with this more intuitive
> alternative: (\S+)\s*$ -> (\S++)\s*+$. But, unless there's some basic
> error on my part, then the possessive replacement ate the proverbial
> dust even of the backtracking regex.

BTW:
-----------
use Benchmark qw(cmpthese);

use constant MAX_WORDS =>	15;
use constant MAX_LEN =>		20;
use constant LINES =>		100;

my (@lines, $line, $n, $nw, $x);

srand(0xdeafbabe);			# repeatable

$n = LINES;
do {
    $nw = int(rand(MAX_WORDS - 2)) + 2;
    $line = '';
    do {
	$line .= 'x' x (int(rand(MAX_LEN - 1)) + 1);
	$line .= ' ' x (rand(5) + 1) if $nw > 1;
    } while --$nw;

    push(@lines, $line);
#    print STDERR ("'$line'\n");
} while --$n;

cmpthese(-3,
	 {
	  split => sub {
	      $x = (split(/\s+/, $_))[-1] for @lines;
	 },

	  renb => sub {
	      /.*\s(\S+)$/ and $x = $1 for @lines;
	  },
	  
	  rere => sub {
	     reverse($_) =~ /^(\S+)/ and $x = reverse($1) for @lines;
	 }});


------------------------------

Date: Sat, 2 Nov 2013 03:56:48 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Can this be combined into one statement?
Message-Id: <l51t60$glf$1@reader1.panix.com>

In article <MPG.2cdc641dc3ed1bd989797@news.eternal-september.org>,
John Black  <jblack@nospam.com> wrote:
>Ben, thanks for the detailed explanation.  This is good stuff to keep
>in mind when in a performance critical loop, but if I were doing this
>again, I would still go with /(\S+)\s*$/ because it is (to me) much
>more clear about what its doing.

I think the split(...) version is clearer still, and that's what I
would use.

-- 
Tim McDaniel, tmcd@panix.com


------------------------------

Date: Fri, 1 Nov 2013 21:03:17 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Can this be combined into one statement?
Message-Id: <cbeb3536-c586-4c2f-9f76-308737fbef88@googlegroups.com>

On Friday, November 1, 2013 2:34:10 PM UTC-7, Rainer Weikusat wrote:
> Charles DeRykus <derykus@gmail.com> writes:
> 
> > On 10/30/2013 11:29 AM, Ben Morrow wrote:
> 
> >>
> 
> >>>
> 
> >>> Why does /(\S+)\s*$/ have to backtrack over "the whole string" whereas
> 
> >>> /.*\s(\S+)/ does not?
> 
> >>> I'm sure I don't undertand regex backtracking...
> 
> >>
> 
> >> Consider a string like "foo bar baz ". For /\S+\s*$/ perl tries the
> 
> >> following sequence of matches:
> 
> 
> 
> [...]
> 
> 
> 
> > I thought a possessive quantifier would help with this more intuitive
> 
> > alternative: (\S+)\s*$ -> (\S++)\s*+$. But, unless there's some basic
> 
> > error on my part, then the possessive replacement ate the proverbial
> 
> > dust even of the backtracking regex.
> 
> BTW:
> -----------
> use Benchmark qw(cmpthese);
> 
> use constant MAX_WORDS =>	15;
> use constant MAX_LEN =>		20;
> use constant LINES =>		100;
> 
> my (@lines, $line, $n, $nw, $x);
> srand(0xdeafbabe);			# repeatable
> $n = LINES;
> 
> do {
>     $nw = int(rand(MAX_WORDS - 2)) + 2;
>     $line = '';
>     do { 
> 	$line .= 'x' x (int(rand(MAX_LEN - 1)) + 1);
> 	$line .= ' ' x (rand(5) + 1) if $nw > 1;
>     } while --$nw;
>     push(@lines, $line); 
> #    print STDERR ("'$line'\n");
> } while --$n;
>
> cmpthese(-3,
> 	 {
> 	  split => sub {
> 	      $x = (split(/\s+/, $_))[-1] for @lines; 
>	 },
>
> 	  renb => sub {
> 	      /.*\s(\S+)$/ and $x = $1 for @lines;
> 	  },
>
> 	  rere => sub {
> 	     reverse($_) =~ /^(\S+)/ and $x = reverse($1) for @lines;
> 	 }});


'rere'  proves going 'reverse' can be a great idea.

(even does well as MAX_LENGTH grows... of course
split wins if you get crazy big)

-- 
Charles DeRykus


------------------------------

Date: Sat, 2 Nov 2013 13:12:25 -0500
From: John Black <jblack@nospam.com>
Subject: Re: Can this be combined into one statement?
Message-Id: <MPG.2cdefc8746de5908989798@news.eternal-september.org>

In article <l51t60$glf$1@reader1.panix.com>, tmcd@panix.com says...
> 
> In article <MPG.2cdc641dc3ed1bd989797@news.eternal-september.org>,
> John Black  <jblack@nospam.com> wrote:
> >Ben, thanks for the detailed explanation.  This is good stuff to keep
> >in mind when in a performance critical loop, but if I were doing this
> >again, I would still go with /(\S+)\s*$/ because it is (to me) much
> >more clear about what its doing.
> 
> I think the split(...) version is clearer still, and that's what I
> would use.

I can't disagree.

John Black


------------------------------

Date: Sun, 03 Nov 2013 14:37:44 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Can this be combined into one statement?
Message-Id: <87fvrdpn47.fsf@sable.mobileactivedefense.com>

tmcd@panix.com (Tim McDaniel) writes:
> John Black  <jblack@nospam.com> wrote:
>>Ben, thanks for the detailed explanation.  This is good stuff to keep
>>in mind when in a performance critical loop, but if I were doing this
>>again, I would still go with /(\S+)\s*$/ because it is (to me) much
>>more clear about what its doing.
>
> I think the split(...) version is clearer still, and that's what I
> would use.

But that's really nothing except /.*\s(\S+)\s*/ written in a different
way: It parses the string from left to right in order to create a list
of words aka

split(/\s+/, $line)

this has to happen in list context, otherwise, it won't work as intended
which makes

(split(/\s+/, $line))

this will look very much like a spurious pair of parentheses to someone
who is not familiar with the split documentation. Lastly, after the list
has been 'captured' in this way, it is indexed by -1

(split(/\s+/, $line))[-1]

In Perl, this means 'count backwards from the end of the list'. In other
languages, it means something different or is invalid altogether.

All of this combined doesn't exactly strike me as a particularly clear
way to express 'get the last word from a string'. Imagine these were
words written on paper and you were asked to cut the last word off the
sentence with a pair of scissors. The idea to start cutting the whole
strip of paper into pieces and drop them all on the floor except the
last one could be made into a nice sketch (skit?) if the piece of paper
was long enough and most people watching this would consider the person
doing it less-than-intellectually-gifted and "but's that what I always
do" (aka 'the construct is familiar to me') wouldn't improve this.



------------------------------

Date: Sat, 02 Nov 2013 00:05:46 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: dir is open
Message-Id: <l518k5$ilc$1@news.ntua.gr>

how do I know if a directory is open so not have warnings when closedir 
  it ? At files there is the fileno.


------------------------------

Date: Fri, 01 Nov 2013 17:17:19 -0700
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: dir is open
Message-Id: <f3h8795ckfpbvc0fdhu70mih51lpurqvug@4ax.com>

George Mpouras <gravitalsun@hotmail.foo> wrote:
>how do I know if a directory is open so not have warnings when closedir 
>  it ? At files there is the fileno.

By checking the return value of opendir()?

jue


------------------------------

Date: Sat, 2 Nov 2013 04:19:31 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: dir is open
Message-Id: <j3beka-r1e1.ln1@anubis.morrow.me.uk>


Quoth Jrgen Exner <jurgenex@hotmail.com>:
> George Mpouras <gravitalsun@hotmail.foo> wrote:
> >how do I know if a directory is open so not have warnings when closedir 
> >  it ? At files there is the fileno.
> 
> By checking the return value of opendir()?

There is a potentially interesting question here, which is 'is it
possible to determine nondestructively if a variable holds an open
dirhandle?' (Analogously to Scalar::Util::openhandle.) AFAICT the only
answer is 'eval { telldir $X; 1 }', which rather clumsy. (It isn't even
possible to use B for this, since IO->DIRP isn't wrapped.)

Perl's support for dirhandles has always been a little limited. Probably
fileno ought to work on dirhandles, at least on systems where the
underlying fd can be extracted from the DIR*. Perl [perl] already does
this to support chdir(DIRHANDLE) and stat(DIRHANDLE), but doesn't expose
the information to Perl.

Ben



------------------------------

Date: Fri, 01 Nov 2013 22:37:10 -0700
From: "$Bill" <bill@todbe.com>
Subject: Re: dir is open
Message-Id: <l52324$lpa$1@dont-email.me>

On 11/1/2013 15:05, George Mpouras wrote:
> how do I know if a directory is open so not have warnings when closedir  it ? At files there is the fileno.

Something to this effect should work:

my $dh;
opendir $dh, $_ or do { warn "open $_ failed: $! ($^E)\n"; undef $dh; };

 ...
readdir $dh, ...
 ...


closedir $dh if $defined $dh;


------------------------------

Date: Sat, 02 Nov 2013 15:07:55 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: dir is open
Message-Id: <l52tfo$1r7o$1@news.ntua.gr>

Στις 2/11/2013 7:37 πμ, ο/η $Bill έγραψε:
> y $dh;
> opendir $dh, $_ or do { warn "open $_ failed: $! ($^E)\n"; undef $dh; };
>
> ...
> readdir $dh, ...
> ...
>
>
> closedir $dh if $defined $dh;




this is a very good idea.

I wonder where is this Perl mystic cryptic where the handles are kept.
fileno knows it , but dirhandles are not there , but there must be also 
one for the dirhandles


------------------------------

Date: Sat, 02 Nov 2013 14:38:56 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: dir is open
Message-Id: <87zjpmuav3.fsf@sable.mobileactivedefense.com>

George Mpouras <gravitalsun@hotmail.foo> writes:
> Στις 2/11/2013 7:37 πμ, ο/η $Bill έγραψε:
>> y $dh;
>> opendir $dh, $_ or do { warn "open $_ failed: $! ($^E)\n"; undef $dh; };
>>
>> ...
>> readdir $dh, ...
>> ...
>>
>>
>> closedir $dh if $defined $dh;
>
>
>
>
> this is a very good idea.

To a degree: perl knows if the directory handle is open and will close
it automatically when the corresponding object is destroyed. This means
this will work:

my $dh;
opendir($dh, '/tmp') if rand(10) > 5;
$dh = undef;

or this

{
	my $dh;
        # do something which might open a dir handle
}
# will be closed here if it was opened


------------------------------

Date: Sat, 02 Nov 2013 09:43:18 -0700
From: "$Bill" <bill@todbe.com>
Subject: Re: dir is open
Message-Id: <l53a33$fct$1@dont-email.me>

On 11/2/2013 07:38, Rainer Weikusat wrote:
>
> To a degree: perl knows if the directory handle is open and will close
> it automatically when the corresponding object is destroyed. This means
> this will work:
>
> my $dh;
> opendir($dh, '/tmp') if rand(10) > 5;
> $dh = undef;

But obviously, you can't do the undef until after the readdir/closedir
is done or you get no dir entries.

> or this
>
> {
> 	my $dh;
>          # do something which might open a dir handle
> }
> # will be closed here if it was opened
>



------------------------------

Date: Sat, 02 Nov 2013 13:49:41 -0700
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: dir is open
Message-Id: <l53ohf$6qq$1@speranza.aioe.org>

On 11/2/2013 6:07 AM, George Mpouras wrote:
> Στις 2/11/2013 7:37 πμ, ο/η $Bill έγραψε:
>> y $dh;
>> opendir $dh, $_ or do { warn "open $_ failed: $! ($^E)\n"; undef $dh; };
>>
>> ...
>> readdir $dh, ...
>> ...
>> closedir $dh if $defined $dh;
>
> this is a very good idea.
>
> I wonder where is this Perl mystic cryptic where the handles are kept.
> fileno knows it , but dirhandles are not there , but there must be also
> one for the dirhandles

Yes, see Ben's response.

So perhaps another slightly "better" hack:

    closedir $dh if ref $dh eq 'GLOB';

-- 
Charles DeRykus


------------------------------

Date: Sat, 2 Nov 2013 22:57:04 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: dir is open
Message-Id: <0jcgka-taq1.ln1@anubis.morrow.me.uk>


Quoth Charles DeRykus <derykus@gmail.com>:
> On 11/2/2013 6:07 AM, George Mpouras wrote:
> > Στις 2/11/2013 7:37 πμ, ο/η $Bill έγραψε:
> >> y $dh;
> >> opendir $dh, $_ or do { warn "open $_ failed: $! ($^E)\n"; undef $dh; };
> >>
> >> ...
> >> readdir $dh, ...
> >> ...
> >> closedir $dh if $defined $dh;
> >
> > this is a very good idea.
> >
> > I wonder where is this Perl mystic cryptic where the handles are kept.

It's called IoDIRP, and it's part of the *$dh{IO} slot of a glob.

> > fileno knows it , but dirhandles are not there , but there must be also
> > one for the dirhandles

Yes, IOs actually contain three handles: IoIFP and IoOFP are the input
and output filehandles (under some circumstances they need to be
different, for reasons I can't remember), and IoDIRP is the dirhandle.

> Yes, see Ben's response.
> 
> So perhaps another slightly "better" hack:
> 
>     closedir $dh if ref $dh eq 'GLOB';

I don't think this helps, does it? You still need eval if you want to
pass in arbitrary scalars.

Ben



------------------------------

Date: Sat, 02 Nov 2013 18:56:01 -0700
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: dir is open
Message-Id: <l54afu$f6o$1@speranza.aioe.org>

On 11/2/2013 3:57 PM, Ben Morrow wrote:
>
> Quoth Charles DeRykus <derykus@gmail.com>:
>> On 11/2/2013 6:07 AM, George Mpouras wrote:
> ...
>>>> closedir $dh if $defined $dh;
>>>
>>> this is a very good idea.
>>>
>> ...
>>
>> So perhaps another slightly "better" hack:
>>
>>      closedir $dh if ref $dh eq 'GLOB';
>
> I don't think this helps, does it? You still need eval if you want to
> pass in arbitrary scalars.
>

Indeed, it looked like "eval" was being thoroughly ignored for a 
"defined $dh"  so I suggested the slight improvement.

-- 
Charles DeRykus


------------------------------

Date: Fri, 1 Nov 2013 11:32:27 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: PDF, Excel, LaTeX, and possibly R and sweave
Message-Id: <e5c65e36-96eb-44ca-a00b-eb4a82470876@googlegroups.com>

I've been asked about the automation of a series of reports that are now be=
ing created by hand and printed as hard copies for distribution. I have two=
 questions for the combined experience of this group, both concerning PDF.

First, I produce reports now as csv files, and using Excel::Writer::XLSX as=
 Excel 2010 files. I have no problem with either, as they are both quick, e=
asy, and effective.

Second, I have been using PDF::API2 for years, with good results, but might=
 need to look at other options, such as CAM::PDF. If I'm happy with PDF::AP=
I2, is there an incentive to look at other libraries for the creation of PD=
F files? I might be looking for an excuse to use another library, so this i=
s a case where any reason might be good enough.

Third, I am accustomed to using LaTeX as my general purpose tool for creati=
ng documents (as opposed, for example, to creating them in Word and printin=
g them as a PDF file). What are the advantages/disadvantages to using a Per=
l binding to LaTex, generating LaTeX source by hand and printing with pdfla=
tex, or continuing to use PDF::API2? I'm much more familiar with LaTeX and =
comfortable using it than PDF::API2, and again any reason to start using Pe=
rl/LaTeX might be good enough.

Finally, I suspect that this project might involve the creation of graphics=
 . I have used both gnuplot and R to manually create graphics, and it seems =
to me that, if I use LaTeX, sweave might be a good solution for producing P=
DFs with embedded graphics. I'm just wondering of anyone has experience wit=
h this, or even just an opinion.

Thanks, CC.


------------------------------

Date: Fri, 01 Nov 2013 15:47:09 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: PDF, Excel, LaTeX, and possibly R and sweave
Message-Id: <87ob6394ma.fsf@castleamber.com>

ccc31807 <cartercc@gmail.com> writes:

> I've been asked about the automation of a series of reports that are
> now being created by hand and printed as hard copies for
> distribution. I have two questions for the combined experience of this
> group, both concerning PDF.
>
> First, I produce reports now as csv files, and using
> Excel::Writer::XLSX as Excel 2010 files. I have no problem with
> either, as they are both quick, easy, and effective.
>
> Second, I have been using PDF::API2 for years, with good results, but
> might need to look at other options, such as CAM::PDF. If I'm happy
> with PDF::API2, is there an incentive to look at other libraries for
> the creation of PDF files? I might be looking for an excuse to use
> another library, so this is a case where any reason might be good
> enough.
>
> Third, I am accustomed to using LaTeX as my general purpose tool for
> creating documents (as opposed, for example, to creating them in Word
> and printing them as a PDF file). What are the
> advantages/disadvantages to using a Perl binding to LaTex, generating
> LaTeX source by hand and printing with pdflatex, or continuing to use
> PDF::API2? I'm much more familiar with LaTeX and comfortable using it
> than PDF::API2, and again any reason to start using Perl/LaTeX might
> be good enough.
>
> Finally, I suspect that this project might involve the creation of
> graphics. I have used both gnuplot and R to manually create graphics,
> and it seems to me that, if I use LaTeX, sweave might be a good
> solution for producing PDFs with embedded graphics. I'm just wondering
> of anyone has experience with this, or even just an opinion.

I generate my invoices as follows:

text file -> [ Perl program ] -> xml -> [ saxon ] -> fo -> [ FOP ] -> PDF
                                      _
                                 xslt /|

If you want to learn something new, XSLT/XSL-FO is something I enjoy
having in my toolbox.

You might also want to have a peek at pandoc.

-- 
John Bokma                                                               j3b

Blog: http://johnbokma.com/        Perl Consultancy: http://castleamber.com/
Perl for books:    http://johnbokma.com/perl/help-in-exchange-for-books.html


------------------------------

Date: Fri, 1 Nov 2013 17:37:46 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: PDF, Excel, LaTeX, and possibly R and sweave
Message-Id: <e335774d-08d1-4a6d-ba24-7833bf23c567@googlegroups.com>

On Friday, November 1, 2013 5:47:09 PM UTC-4, John Bokma wrote:

> text file -> [ Perl program ] -> xml -> [ saxon ] -> fo -> [ FOP ] -> PDF
>                                       _
> 
>                                  xslt /|
> 
> 
> 
> If you want to learn something new, XSLT/XSL-FO is something I enjoy
> having in my toolbox.

Years ago, probably around 2003, I used XSLT, and you are right in that it's a great tool to have. I'm not sure what this project will entail, and I thank you for reminding me about XSLT. It may be useful.

I generate most of my work like this:

data-files -> Perl-script -> (csv|HTML|PDF|Excel|email)

CC.


------------------------------

Date: Sat, 2 Nov 2013 03:57:43 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: PDF, Excel, LaTeX, and possibly R and sweave
Message-Id: <nq9eka-8dd1.ln1@anubis.morrow.me.uk>


Quoth ccc31807 <cartercc@gmail.com>:
> 
> Third, I am accustomed to using LaTeX as my general purpose tool for
> creating documents (as opposed, for example, to creating them in Word
> and printing them as a PDF file). What are the advantages/disadvantages
> to using a Perl binding to LaTex,

Does such a creature exist? (Beyond the likes of LaTeX::Driver, which
just automates running latex on generated source.)

> generating LaTeX source by hand and printing with pdflatex,

When you say 'by hand', I assume you mean 'with Perl'? If I were
generating PDFs, this is what I'd do. (Actually I'd use ConTeXt, since
it's easier to control, but that's immaterial here.)

Ben



------------------------------

Date: Sat, 2 Nov 2013 05:42:19 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: PDF, Excel, LaTeX, and possibly R and sweave
Message-Id: <d84b0e97-59f4-459e-92fb-056ea9b4166a@googlegroups.com>

On Friday, November 1, 2013 11:57:43 PM UTC-4, Ben Morrow wrote:
> Does such a creature exist? (Beyond the likes of LaTeX::Driver, which
> just automates running latex on generated source.)

I don't know, which is why I asked the question. Yes, I searched CPAN, but sometimes things are not obvious and we overlook them.

> > generating LaTeX source by hand and printing with pdflatex,
> When you say 'by hand', I assume you mean 'with Perl'? If I were
> generating PDFs, this is what I'd do. (Actually I'd use ConTeXt, since
> it's easier to control, but that's immaterial here.)

'by hand' means typing the commands, like this:
\paragraph{Example}This is a paragraph.

I generate HTML files with Perl like this:
my $var = 'paragraph';
print OUT qq(<html><body><p>This is a $var.</p></body></html>);

I generate csv files the same way:
print CSV qq("$col1","$col2","$col3"\n);

However, I generate Excel files using the OO syntax of the package.

I'm at a point where I will need to do significant new work, and this strikes me as a good time to investigate alternatives. After all, if I'm going to be doing a lot of work, I might as well use it as an opportunity to learn something new and different.

CC.


------------------------------

Date: Sun, 03 Nov 2013 21:29:32 +0100
From: Mart van de Wege <mvdwege@bors.avalon.lan>
Subject: Re: PDF, Excel, LaTeX, and possibly R and sweave
Message-Id: <86zjpl5ivn.fsf@bors.avalon.lan>

ccc31807 <cartercc@gmail.com> writes:
>
> Third, I am accustomed to using LaTeX as my general purpose tool for
> creating documents (as opposed, for example, to creating them in Word
> and printing them as a PDF file). What are the
> advantages/disadvantages to using a Perl binding to LaTex, generating
> LaTeX source by hand and printing with pdflatex, or continuing to use
> PDF::API2? I'm much more familiar with LaTeX and comfortable using it
> than PDF::API2, and again any reason to start using Perl/LaTeX might
> be good enough.
>
> Finally, I suspect that this project might involve the creation of
> graphics. I have used both gnuplot and R to manually create graphics,
> and it seems to me that, if I use LaTeX, sweave might be a good
> solution for producing PDFs with embedded graphics. I'm just wondering
> of anyone has experience with this, or even just an opinion.
>
At my previous employer I used to autogenerate reports for our customers
using LaTeX::Driver with great success.

I also used to generate the graphs for those reports using
SVG::TT::Graph. Not because SVG was easy to bind into LaTeX (that sucked
actually), but because SVG::TT::Graph had a nice API to generate graphs
IMO. I used the ImageMagick bindings to convert the output into
something that LaTeX would like, and Template Toolkit to fill in the
LaTeX documents and generate the links to the graphs.

So, use your favourite graphing module to create your graphics, use
TT LaTeX templates to build your documents, and run the output of the
processed templates through LaTeX::Driver, that's the way I would do it.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4069
***************************************


home help back first fref pref prev next nref lref last post