[31182] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2427 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 19 14:09:49 2009

Date: Tue, 19 May 2009 11:09:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 19 May 2009     Volume: 11 Number: 2427

Today's topics:
    Re: ampersand subroutine <ben@morrow.me.uk>
    Re: ampersand subroutine <tadmc@seesig.invalid>
    Re: ampersand subroutine <cartercc@gmail.com>
    Re: Archive::Zip and correct extension (mixture of Word <gcox@freeuk.com>
    Re: Archive::Zip and correct extension (mixture of Word <gcox@freeuk.com>
    Re: Archive::Zip and correct extension (mixture of Word <tadmc@seesig.invalid>
    Re: Archive::Zip and correct extension (mixture of Word <tadmc@seesig.invalid>
    Re: beginner array of array... thank you all <tzz@lifelogs.com>
        compiled perl question. <DaLoveRhino@hotmail.com>
    Re: compiled perl question. <jurgenex@hotmail.com>
    Re: compiled perl question. <DaLoveRhino@hotmail.com>
    Re: compiled perl question. <yankeeinexile@gmail.com>
    Re: compiled perl question. <yankeeinexile@gmail.com>
    Re: compiled perl question. <jurgenex@hotmail.com>
    Re: compiled perl question. <DaLoveRhino@hotmail.com>
    Re: compiled perl question. <cartercc@gmail.com>
    Re: compiled perl question. <jurgenex@hotmail.com>
        Generate Word and Powerpoint files <ddp23@cam.ac.uk>
    Re: Generate Word and Powerpoint files <cartercc@gmail.com>
    Re: Generate Word and Powerpoint files <smallpond@juno.com>
        Outputting to PDF simply? bobm3@worthless.info
    Re: Outputting to PDF simply? <1usa@llenroc.ude.invalid>
    Re: Outputting to PDF simply? <cartercc@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 19 May 2009 13:40:53 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: ampersand subroutine
Message-Id: <lvlae6-jo1.ln1@osiris.mauzo.dyndns.org>


Quoth Jürgen Exner <jurgenex@hotmail.com>:
> "Guy" <someone@somewhere.nb.ca> wrote:
> >I've seen some code that call user subroutines without the ampersand.  I 
> >didn't know you could do that.
> 
> It has different semantics, so it depends upon what you want/need.
> 
> >So I read that you can omit the ampersand if "the compiler sees the 
> >subroutine definition before invocation or..."
> 
> >But instead of declaring all my subroutines at the begining of my script, or 
> >ensuring they're located ahead of invocation, wouldn't it just be safer and 
> >even easier to always have the ampersand? or are ampersand really a thing of 
> >the past when not absolutely needed?
> 
> You got the wrong idea. Actually several wrong ideas.
> 1: where if not at the beginning of your script do you define your subs?
> You don't do that in the middle of the main body, do you?

Putting the 'main' code at the beginning and the subs at the end is not
a bad idea. It means the script reads top-down, so you get a general
overview of what it does before seeing the detail.

And, of course, where you have both A calls B and B calls A at least one
of them must be defined after it is first called.

> 2: as you wrote correctly the declaration has to be before the
> invocation, while the definition of the sub can be anywhere, even
> textually after its invocation

For clarity, a 'declaration' is a line like

    sub foo;

or like

    use subs qw/foo bar/;

which says 'I am going to define these subs later'. You can call user
subs with neither leading ampersand ampersand nor trailing parens after
only a declaration.

> 3: the ampersand is not "a thing of the past". It modifies the calling
> semantic, such that 
> 	a) prototypes are overridden
> 	b) @_ is visible to the called sub

(To the OP:) This is good advice and you should listen :).

In general, the straightforward, modern (ie., since Perl 5) way to call
a sub without a declaration in scope is to put parens around its
arguments, or to put an empty set of parens after the name if it doesn't
have any.

    use strict;

    # This is a 'strict' error.
    foo;

    # This is a sub call.
    foo(1, 2, 3);

    # So is this.
    foo();

    # This is a declaration.
    sub foo;

    # Now these are sub calls.
    foo 1, 2, 3;
    foo;

Ben



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

Date: Tue, 19 May 2009 07:45:08 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: ampersand subroutine
Message-Id: <slrnh15aek.6a9.tadmc@tadmc30.sbcglobal.net>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> "Guy" <someone@somewhere.nb.ca> wrote:
>>I've seen some code that call user subroutines without the ampersand.  I 
>>didn't know you could do that.
>
> It has different semantics, so it depends upon what you want/need.


(with a subtext of "you almost never want the semantics that ampersand gives")


>>So I read 


Where did you read it?


>> that you can omit the ampersand if "the compiler sees the 
>>subroutine definition before invocation or..."


The above was a rhetorical question, as I recognize that quote
from the Llama book.

You snipped the part after the "or":

    if Perl can tell from the syntax that it's a subroutine call

All of my code makes use of that snipped part.


>>But instead of declaring all my subroutines at the begining of my script, or 
>>ensuring they're located ahead of invocation, 


I define my subroutines at the end of my program, after the main code.

I do not declare my subroutines either.

("define" and "declare" mean different things.)

Yet I never use ampersand on subroutine calls.


So how do my programs end up working then?

I make use of the part after the "or"...

 ... I always use parenthesis when calling my user-defined subroutines.


>> wouldn't it just be safer and 
>>even easier to always have the ampersand? 


Both approaches have "safety" issues.

Using the ampersand may invoke the often unwanted semantics mentioned below.

Using only parenthesis may call a built-in subroutine with the 
same name rather than the user-defined subroutine.


>> or are ampersand really a thing of 
>>the past when not absolutely needed?
>
> You got the wrong idea. Actually several wrong ideas.
> 1: where if not at the beginning of your script do you define your subs?
> You don't do that in the middle of the main body, do you?


I do it at the end.


> 2: as you wrote correctly the declaration has to be before the
> invocation, 


 ... or you must use parenthesis around the argument list.


> while the definition of the sub can be anywhere, even
> textually after its invocation
> 3: the ampersand is not "a thing of the past". It modifies the calling
> semantic, such that 
> 	a) prototypes are overridden
> 	b) @_ is visible to the called sub
> (for details see perldoc perlsub).
> If you want that semantic (which IMO is somewhat screwy) then use
> ampersands. For normal programs it causes too many unwanted
> dependencies, so I advise against using them. It is just easier not
> having to deal with them.


Debugging when the ampersand approach is used can be really tricky.

Debugging when the parenthesis approach is used is easy. Just do a

    perldoc -f my_func

If it returns docs for my_func(), then choose a different name
for your user-defined subroutine.

So as Jürgen said, it is not a thing of the past.

However, the "when not absolutely needed" part _is_ correct.

The ampersand is absolutely needed if you want the above special
treatment of the sub's argument list or if you insist on using
the same name as a built-in.

It is rare to want or need the arg special treatment, and I do not
recommend reusing the name of a built-in Perl function.


So if you follow a simple rule, you won't have much to worry about:

    Never use ampersand on subroutine calls, always use parenthesis
    on (user-defined) subroutine calls (but watch out for name collisions)



-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 19 May 2009 08:17:15 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: ampersand subroutine
Message-Id: <7880e6ce-ee08-4a55-9120-add7e8083a06@n8g2000vbb.googlegroups.com>

On May 19, 8:40=A0am, Ben Morrow <b...@morrow.me.uk> wrote:
> Putting the 'main' code at the beginning and the subs at the end is not
> a bad idea. It means the script reads top-down, so you get a general
> overview of what it does before seeing the detail.

Absolutely! In general, you might find yourself writing 'main' code
that's simply a sequence of function calls with only a few lines of
code, and your functions defined AFTER your program exits, and a
separate section, labled and documented.

Or better yet, if you have a number of user defined functions, in
modules with descriptive names, like a C program with a very short
main function but a number of include files that contain your
functionality.

CC



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

Date: Tue, 19 May 2009 11:48:27 +0100
From: Geoff Cox <gcox@freeuk.com>
Subject: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
Message-Id: <mf35151epinp9oo0vcdh9v3hphgt7nq5an@4ax.com>

On Mon, 18 May 2009 19:49:22 -0500, Tad J McClellan
<tadmc@seesig.invalid> wrote:

Tad,

I'm going round in circles!

I get error message "can't call method "memberNames" on undefined
value" 

I've made a sill mistake somewhere - what is it?

Cheers,

Geoff

use warnings;
use strict;

use File::Find;
use Archive::Zip;

my $dir = 'c:/a-temp2/docs';

find( sub {
    my $zip = Archive::Zip->new( $_ );
    my($arch_ext) = ($zip->memberNames)[ 0 ];
    $arch_ext =~ s/.*\.//;   # strip all but the extension
    my $basename = $_;
    $basename =~ s/\..*//;  # strip off the extension
    $zip->extractMember( ($zip->memberNames)[ 0 ],
"$basename.$arch_ext" );
    unlink $_ or warn "Cannot delete $_: $!";
    }, $dir );



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

Date: Tue, 19 May 2009 12:07:00 +0100
From: Geoff Cox <gcox@freeuk.com>
Subject: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
Message-Id: <uj45151m3fsovre149mechse52hd2gdvut@4ax.com>

On Mon, 18 May 2009 19:49:22 -0500, Tad J McClellan
<tadmc@seesig.invalid> wrote:


Tad,

I have the code working but cannot see why it is right to have the

( my $name = $_ ) =~ s/\.zip$/.doc/i or return;

line as it seems to be to change all .zip to .doc ?!

What am I missing?

Geoff


use warnings;
use strict;

use File::Find;
use Archive::Zip;

my $dir = 'c:/a-temp2/docs';

find( sub {
    ( my $name = $_ ) =~ s/\.zip$/.doc/i or return;
    my $zip = Archive::Zip->new( $_ );
    my($arch_ext) = ($zip->memberNames)[ 0 ];
    $arch_ext =~ s/.*\.//;   # strip all but the extension
    my $basename = $_;
    $basename =~ s/\..*//;  # strip off the extension
    $zip->extractMember( ($zip->memberNames)[ 0 ],
"$basename.$arch_ext" );
    unlink $_ or warn "Cannot delete $_: $!";
    }, $dir );


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

Date: Tue, 19 May 2009 06:51:52 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
Message-Id: <slrnh157ao.6a9.tadmc@tadmc30.sbcglobal.net>

Geoff Cox <gcox@freeuk.com> wrote:
> On Mon, 18 May 2009 19:49:22 -0500, Tad J McClellan
><tadmc@seesig.invalid> wrote:


You did not quote anything that I wrote.


> I get error message "can't call method "memberNames" on undefined
> value" 
>
> I've made a sill mistake somewhere - what is it?


Not reading the docs for the module you are using.


>     my $zip = Archive::Zip->new( $_ );


    perldoc Archive::Zip

       new( [$fileName] )
           Make a new, empty zip archive.

               my $zip = Archive::Zipâ€>new();

           If an additional argument is passed, new() will call read() to read
           the contents of an archive:

               my $zip = Archive::Zipâ€>new( ’xyz.zip’ );

           If a filename argument is passed and the read fails for any reason,
           new will return undef. For this reason, it may be better to call
           read separately.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 19 May 2009 06:58:37 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
Message-Id: <slrnh157nd.6a9.tadmc@tadmc30.sbcglobal.net>

Geoff Cox <gcox@freeuk.com> wrote:
> On Mon, 18 May 2009 19:49:22 -0500, Tad J McClellan
><tadmc@seesig.invalid> wrote:
>
>
> Tad,
>
> I have the code working but cannot see why it is right to have the
>
> ( my $name = $_ ) =~ s/\.zip$/.doc/i or return;
>
> line as it seems to be to change all .zip to .doc ?!


Yes, that is what it is supposed to do.

But your code no longer makes use of the $name variable.


> What am I missing?


You changed the requirements.

If you change the requirements, the code wil likely need to be changed.


>     ( my $name = $_ ) =~ s/\.zip$/.doc/i or return;


That is vestigial.

It used to have a purpose, but now has no purpose.

If you no longer want to replace with "doc", then you need to remove
code that replaces with "doc".


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 19 May 2009 10:52:50 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: beginner array of array... thank you all
Message-Id: <86d4a59jjh.fsf@lifelogs.com>

On Mon, 18 May 2009 18:46:11 -0400 "Uri Guttman" <uri@PerlOnCall.com> wrote: 

UG> you should learn it now. indexing fields by number and not name is prone
UG> to bugs and misunderstanding later. this will bite you one day for sure
UG> so learn hashes now. 

Arrays use less memory, which can become important for some
applications.  If I face that situation, I usually use constants to
reduce the chance of error:

use constant NAME => 0;
use constant SURNAME => 1;

my @data;
$data[NAME] = 'John';

Obviously Uri's advice is valid too, it's just that in some cases you
are forced to use arrays.

Ted


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

Date: Tue, 19 May 2009 08:40:32 -0700 (PDT)
From: DaLoverhino <DaLoveRhino@hotmail.com>
Subject: compiled perl question.
Message-Id: <a978ac87-2c9e-4371-9b8d-22b1af68438d@x6g2000vbg.googlegroups.com>

I read somewhere that perl gets compiled to bytecodes and is run in a
perl virtual machine similar to Java.  Is that true?  What I'd like to
do is give a bytecode compiled version of my perl script, but not the
script itself, to prevent copying or modifying it.  I'd rather not run
the script through an obfuscator.

Can this be done?  And how?

Can you point me to a link?

thanks.


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

Date: Tue, 19 May 2009 08:45:17 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: compiled perl question.
Message-Id: <cvk5151gus2p3698q0ge8euh2fkho1oigf@4ax.com>

DaLoverhino <DaLoveRhino@hotmail.com> wrote:
>I read somewhere that perl gets compiled to bytecodes and is run in a
>perl virtual machine similar to Java.  Is that true?  What I'd like to
>do is give a bytecode compiled version of my perl script, but not the
>script itself, to prevent copying or modifying it.  I'd rather not run
>the script through an obfuscator.

perldoc -q hide

  How can I hide the source for my Perl program?

jue


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

Date: Tue, 19 May 2009 08:54:04 -0700 (PDT)
From: DaLoverhino <DaLoveRhino@hotmail.com>
Subject: Re: compiled perl question.
Message-Id: <d6be8504-b20c-4892-a332-cecfd4a34607@n8g2000vbb.googlegroups.com>

On May 19, 11:45=A0am, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> DaLoverhino <DaLoveRh...@hotmail.com> wrote:
> >I read somewhere that perl gets compiled to bytecodes and is run in a
> >perl virtual machine similar to Java. =A0Is that true? =A0What I'd like =
to
> >do is give a bytecode compiled version of my perl script, but not the
> >script itself, to prevent copying or modifying it. =A0I'd rather not run
> >the script through an obfuscator.
>
> perldoc -q hide
>
> =A0 How can I hide the source for my Perl program?
>
> jue

Thanks, unfortunately, I don't have perldoc on my system, and I am not
the sys admin of our unix boxes.  Can you copy/past the output of that
command for me onto this thread, please?  Thanks.


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

Date: Tue, 19 May 2009 10:57:41 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: compiled perl question.
Message-Id: <m1ljot13wq.fsf@mac.gateway.2wire.net>

DaLoverhino <DaLoveRhino@hotmail.com> writes:

> On May 19, 11:45 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>> DaLoverhino <DaLoveRh...@hotmail.com> wrote:
>> >I read somewhere that perl gets compiled to bytecodes and is run in a
>> >perl virtual machine similar to Java.  Is that true?  What I'd like to
>> >do is give a bytecode compiled version of my perl script, but not the
>> >script itself, to prevent copying or modifying it.  I'd rather not run
>> >the script through an obfuscator.
>>
>> perldoc -q hide
>>
>>   How can I hide the source for my Perl program?
>>
>> jue
>
> Thanks, unfortunately, I don't have perldoc on my system, and I am not
> the sys admin of our unix boxes.  Can you copy/past the output of that
> command for me onto this thread, please?  Thanks.

If you can't write any executable files anywhere to any filesystem
(which is the only possible explanation for not being able to install a
private copy of perldoc) how can you even produce any code at all?

 


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

Date: Tue, 19 May 2009 11:02:15 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: compiled perl question.
Message-Id: <m1hbzh13p4.fsf@mac.gateway.2wire.net>

DaLoverhino <DaLoveRhino@hotmail.com> writes:
> On May 19, 11:45 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>> DaLoverhino <DaLoveRh...@hotmail.com> wrote:
>> >I read somewhere that perl gets compiled to bytecodes and is run in a
>> >perl virtual machine similar to Java.  Is that true?  What I'd like to
>> >do is give a bytecode compiled version of my perl script, but not the
>> >script itself, to prevent copying or modifying it.  I'd rather not run
>> >the script through an obfuscator.
>>
>> perldoc -q hide
>>
>>   How can I hide the source for my Perl program?
>>
>> jue
>
> Thanks, unfortunately, I don't have perldoc on my system, and I am not
> the sys admin of our unix boxes.  Can you copy/past the output of that
> command for me onto this thread, please?  Thanks.

Oh look ... Google wasn't shut down after all ....

http://perldoc.perl.org/perlfaq3.html#How-can-I-hide-the-source-for-my-Perl-program%3f



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

Date: Tue, 19 May 2009 09:11:05 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: compiled perl question.
Message-Id: <44m515to0fcot5jkpe5mfljbejj8qru5vj@4ax.com>

DaLoverhino <DaLoveRhino@hotmail.com> wrote:
>On May 19, 11:45 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>> DaLoverhino <DaLoveRh...@hotmail.com> wrote:
>> >I read somewhere that perl gets compiled to bytecodes and is run in a
>> >perl virtual machine similar to Java.  Is that true?  What I'd like to
>> >do is give a bytecode compiled version of my perl script, but not the
>> >script itself, to prevent copying or modifying it.  I'd rather not run
>> >the script through an obfuscator.
>>
>> perldoc -q hide
>>
>>   How can I hide the source for my Perl program?
>
>Thanks, unfortunately, I don't have perldoc on my system, 

I don't understand. perldoc is part of Perl. If it isn't installed then
your Perl installation is broken. Maybe fix it?

And how do you manage to program in Perl at all without the
documentation being available? How are you looking up the functionality
of an operator or checking the meaning of a predefined variable or
confirming which type of arguments a function takes?

>and I am not the sys admin of our unix boxes.  

Why don't you create your own installation of Perl instead of using a
broken one?

>Can you copy/past the output of that
>command for me onto this thread, please?  Thanks.

That would be against all Usenet ettiquette, but here's a web link: 
http://perldoc.perl.org/perlfaq3.html#How-can-I-hide-the-source-for-my-Perl-program%3f

jue


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

Date: Tue, 19 May 2009 09:14:40 -0700 (PDT)
From: DaLoverhino <DaLoveRhino@hotmail.com>
Subject: Re: compiled perl question.
Message-Id: <b2fc33d4-de69-4a95-bcc0-dcfae03abe57@r3g2000vbp.googlegroups.com>

On May 19, 11:57=A0am, Lawrence Statton <yankeeinex...@gmail.com> wrote:
> DaLoverhino <DaLoveRh...@hotmail.com> writes:
> > On May 19, 11:45=A0am, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> >> DaLoverhino <DaLoveRh...@hotmail.com> wrote:
> >> >I read somewhere that perl gets compiled to bytecodes and is run in a
> >> >perl virtual machine similar to Java. =A0Is that true? =A0What I'd li=
ke to
> >> >do is give a bytecode compiled version of my perl script, but not the
> >> >script itself, to prevent copying or modifying it. =A0I'd rather not =
run
> >> >the script through an obfuscator.
>
> >> perldoc -q hide
>
> >> =A0 How can I hide the source for my Perl program?
>
> >> jue
>
> > Thanks, unfortunately, I don't have perldoc on my system, and I am not
> > the sys admin of our unix boxes. =A0Can you copy/past the output of tha=
t
> > command for me onto this thread, please? =A0Thanks.
>
> If you can't write any executable files anywhere to any filesystem
> (which is the only possible explanation for not being able to install a
> private copy of perldoc) how can you even produce any code at all?

I guess because perldoc is 32mb file, and I don't have the space on my
account.  Using the keyword 'hide', I was able to find some links.
Thanks for the help.




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

Date: Tue, 19 May 2009 09:16:41 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: compiled perl question.
Message-Id: <3a1f09fb-a934-47ab-9e0c-3f9f31d5e5b1@j12g2000vbl.googlegroups.com>

On May 19, 11:40=A0am, DaLoverhino <DaLoveRh...@hotmail.com> wrote:
>  =A0What I'd like to
> do is give a bytecode compiled version of my perl script, but not the
> script itself, to prevent copying or modifying it. =A0I'd rather not run
> the script through an obfuscator.

Look at perlcc. I've used it to generate an exe file on Linux, but
it's real ugly and results in a very large file.

CC


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

Date: Tue, 19 May 2009 09:29:12 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: compiled perl question.
Message-Id: <mrm515t6050f4kbub8p5dsgo9jk57hev1l@4ax.com>

DaLoverhino <DaLoveRhino@hotmail.com> wrote:
>On May 19, 11:57 am, Lawrence Statton <yankeeinex...@gmail.com> wrote:
>> DaLoverhino <DaLoveRh...@hotmail.com> writes:
>> > On May 19, 11:45 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>> >> DaLoverhino <DaLoveRh...@hotmail.com> wrote:
>> >> >I read somewhere that perl gets compiled to bytecodes and is run in a
>> >> >perl virtual machine similar to Java.  Is that true?  What I'd like to
>> >> >do is give a bytecode compiled version of my perl script, but not the
>> >> >script itself, to prevent copying or modifying it.  I'd rather not run
>> >> >the script through an obfuscator.
>>
>> >> perldoc -q hide
>>
>> >>   How can I hide the source for my Perl program?
>>
>> >> jue
>>
>> > Thanks, unfortunately, I don't have perldoc on my system, and I am not
>> > the sys admin of our unix boxes.  Can you copy/past the output of that
>> > command for me onto this thread, please?  Thanks.
>>
>I guess because perldoc is 32mb file, and I don't have the space on my
>account.  

I think you meant 32MB, not 32 millibar.

Owwww, wait a second. Are we living in the same year? 1TB drives go for
just over about 100$ US nowadays. That translates into those 32MB
costing about 0.32 Cent US. Are you saying your employer or university
or whoever owns those machines cannot afford 1/3 of a cent to have a
working Perl installation? But they can afford their employees writing
programs without having the documentation they need.
I had not idea the economic crisis was that bad.

jue


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

Date: 19 May 2009 15:23:36 GMT
From: Daniel Parry <ddp23@cam.ac.uk>
Subject: Generate Word and Powerpoint files
Message-Id: <slrnh15jno.6v9.ddp23@pip.srcf.ucam.org>

I'd like to generate word and power point files on a linux based
system. Populated with various random words from a dictionary to
create various different size files. I have this working for: 
Excel, HTML, JSON, ODT, PDF, RTF, Text, and XML format but stumped
a bit for doc and ppt. Any one have any suggestions for hacks that
might make these last two formats possible, which don't include
starting up a windows instance somehow (^_^)

Thanks and best wishes,

Daniel


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

Date: Tue, 19 May 2009 09:07:00 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Generate Word and Powerpoint files
Message-Id: <9bc1ce96-86c8-4b2b-8eb9-9d94f2a9e987@o14g2000vbo.googlegroups.com>

On May 19, 11:23=A0am, Daniel Parry <dd...@cam.ac.uk> wrote:
> I'd like to generate word and power point files on a linux based
> system.

Create XML documents using OOXML. It's as easy as using Perl for HTML
documents.

http://en.wikipedia.org/wiki/Office_Open_XML

http://rep.oio.dk/Microsoft.com/officeschemas/wordprocessingml_article.htm

http://wiki.services.openoffice.org/wiki/PresentationML

CC


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

Date: Tue, 19 May 2009 10:41:46 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Generate Word and Powerpoint files
Message-Id: <49a4aaae-fc5d-49ed-86a0-5b8c2337bcb6@n21g2000vba.googlegroups.com>

On May 19, 11:23=A0am, Daniel Parry <dd...@cam.ac.uk> wrote:
> I'd like to generate word and power point files on a linux based
> system. Populated with various random words from a dictionary to
> create various different size files. I have this working for:
> Excel, HTML, JSON, ODT, PDF, RTF, Text, and XML format but stumped
> a bit for doc and ppt. Any one have any suggestions for hacks that
> might make these last two formats possible, which don't include
> starting up a windows instance somehow (^_^)
>
> Thanks and best wishes,
>
> Daniel

Please post a spec for those formats.


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

Date: Tue, 19 May 2009 10:34:08 -0400
From: bobm3@worthless.info
Subject: Outputting to PDF simply?
Message-Id: <bng515l0ltk5ftcd0i4nrs386ofc6cpcjp@4ax.com>

Fellow mongers...

I've searched CPAN as well as googled for numerous pdf creator
utilities.  I've read about some of the perl modules available (i.e.:
PDF::API, PDF::Report, PDF::ReportWriter, etc).

I think all these are overkill for what I am trying to do.  Perhaps
some of you can recommend a workable solution that I can research and
hopefully incorporate.  

I have some perl programs that create business reports using the
write(format) feature (which works very well, BTW) and they are now
creating text output.  I would like to have those converted to or
output directly as PDF's so they can be more easily opened for
viewing, searching  and printing with Acrobat.

Any recommendations as to what my fill this bill with the least amount
of changes?

Thanks all for your kind and knowledgeable advice!


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

Date: Tue, 19 May 2009 14:52:17 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Outputting to PDF simply?
Message-Id: <Xns9C106E9654ED4asu1cornelledu@127.0.0.1>

bobm3@worthless.info wrote in news:bng515l0ltk5ftcd0i4nrs386ofc6cpcjp@
4ax.com:

> I have some perl programs that create business reports using the
> write(format) feature (which works very well, BTW) and they are now
> creating text output.  I would like to have those converted to or
> output directly as PDF's so they can be more easily opened for
> viewing, searching  and printing with Acrobat.

Run a2ps and ps2pdf on the output.

http://www.gnu.org/software/a2ps/

http://www.ghostscript.com/

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Tue, 19 May 2009 08:07:21 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Outputting to PDF simply?
Message-Id: <fe0dbc1c-dae3-4d8e-8f4a-609db91331e2@t11g2000vbc.googlegroups.com>

On May 19, 10:34=A0am, bo...@worthless.info wrote:
> I have some perl programs that create business reports using the
> write(format) feature (which works very well, BTW) and they are now
> creating text output. =A0I would like to have those converted to or
> output directly as PDF's so they can be more easily opened for
> viewing, searching =A0and printing with Acrobat.

'Simple' might be in the eye of the beholder. I use PDF::API2. One of
the scripts I use it is for the creation of about 5,000 contracts five
times a year, and it does exactly what you would expect -- create
about 5,000 PDF documents, along with a cover letter and instructions.

Yes, you do have to write each line, but that's no harder than hand
writing HTML or creating a format, and it variable interpolates so you
can write templates. I've included a sample below.

CC

-----------sample using PDF::API2--------------------
    $text->fillcolor('black');
    $text->font( $font{'Times'}{'Bold'}, 11/pt );

    $text->translate( 72, 580 );
    $text->text("Greetings, $fac_contract{FIRST} $fac_contract{MIDDLE}
$fac_contract{LAST},");

    $text->fillcolor('black');
    $text->font( $font{'Times'}{'Roman'}, 11/pt );

    $text->translate( 72, 560);
    $text->text("The following is information for reviewing and
completing your Term $fac_contract{TERM} adjunct contract. After");

    $text->translate( 72, 550);
    $text->text("you have reviewed your contract, print and sign as
Faculty Appointee. Mail it to the address listed");

    $text->translate( 72, 540);
    $text->text("below as soon as possible.");

    $text->font( $font{'Helvetica'}{'Bold'}, 12/pt );
    $text->fillcolor('darkred');

    $text->translate( 72, 500);
    $text->text("Need to change your address, phone number?");


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

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:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#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 2427
***************************************


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