[30697] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1942 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 23 21:09:45 2008

Date: Thu, 23 Oct 2008 18:09:14 -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           Thu, 23 Oct 2008     Volume: 11 Number: 1942

Today's topics:
    Re: Apache2 mod_perl, missing File.pm, cant use Compres <glex_no-spam@qwest-spam-no.invalid>
    Re: can LWP handle this? <ced@blv-sam-01.ca.boeing.com>
        Comparison of two files.. clearguy02@yahoo.com
        Connect to MS SQL 2005 server from UNIX <slick.users@gmail.com>
    Re: Connect to MS SQL 2005 server from UNIX <danrumney@warpmail.net>
    Re: Filehandle STDIN reopened as $fh1 only for output xhoster@gmail.com
    Re: Filehandle STDIN reopened as $fh1 only for output <whynot@pozharski.name>
    Re: Filehandle STDIN reopened as $fh1 only for output <nospam-abuse@ilyaz.org>
        Fine tuning appearance of charts produced by Chart::Lin <r.ted.byers@gmail.com>
    Re: Is it possible to store an SV in C pointer <fawaka@gmail.com>
    Re: Is it possible to store an SV in C pointer <u8526505@gmail.com>
    Re: question about data structures - what does $# mean? <usenet@davidfilmer.com>
    Re: Question on the length of a Scalar <rvtol+news@isolution.nl>
        Script for uploading files to a server <grega@kt.agh.edu.pl>
    Re: Script for uploading files to a server <joost@zeekat.nl>
    Re: Script for uploading files to a server <grega@kt.agh.edu.pl>
        Unix, Perl, IE, and Excel <cartercc@gmail.com>
    Re: Unix, Perl, IE, and Excel <usenet@davidfilmer.com>
    Re: Unix, Perl, IE, and Excel <glex_no-spam@qwest-spam-no.invalid>
    Re: Unix, Perl, IE, and Excel <cartercc@gmail.com>
    Re: Unix, Perl, IE, and Excel (J.D. Baldwin)
    Re: Unix, Perl, IE, and Excel (fidokomik\)
    Re: Where is the documentation to show how to add a PNG <bill@ts1000.us>
    Re: Where is the documentation to show how to add a PNG <thepoet_nospam@arcor.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Oct 2008 17:24:03 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Apache2 mod_perl, missing File.pm, cant use Compress
Message-Id: <4900f983$0$89386$815e3792@news.qwest.net>

Holger Banko wrote:
> I am trying to migrate a website from mod_perl1.0 to mod_perl2.0 and I
> am a complete noob when it comes to Perl. I got already stuck with pre-
> loading of the Compress Module. In my Apache configuration it looks
> like this
[...]
> I checked the migration guide and found this
> 
> Apache::File
> 
> "The methods from mod_perl 1.0's module Apache::File have been either
> moved to other packages or removed."
> 
> Yes? To which packages? How can I get Compress to work or is there a
> set of Apache2 perl modules?

mod_deflate ???


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

Date: Thu, 23 Oct 2008 13:25:12 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: can LWP handle this?
Message-Id: <f03f5c81-6881-452f-b0c4-17d6572abc1c@r15g2000prh.googlegroups.com>

On Oct 22, 9:20 am, Larry <dontmewit...@got.it> wrote:
> In article <dontmewithme-3D7BF7.17391321102...@news.tin.it>,
>
>  Larry <dontmewit...@got.it> wrote:
> > ok, I sorted out something like the following:
>
> I have found I cannot send an header data before the rwa data:
>
> I cannot do this: # It won't send "Hello World!" at all
>
> $req->content("Hello World!");
>
> $req->content(sub {
>    read($fh1, my $buf, 2048);
>    return $buf;
>  } );
>
> nor this: # It will send only "Hello world!" for ever, like it weren't
> aquainted with $_hsent = 1;
>
> $_hsent = 0;
>
> $req->content(sub {
>    if $_hsent == 0
>    {
>       return "Hello World!";
>       $_hsent = 1;
>    } else {
>       read($fh1, my $buf, 2048);
>       return $buf;
>    }
>  } );
>
> any idea?
>

Untested but a possible simpler alternative:

$hello = "Hello World!";
$len = length $hello;

$req->add_content($hello);
while ( $num = read($fh1, my $buf, 2048) ) {
     $len += $num;
     $request->add_content($buf);
}
die "read error: $!" unless defined $num;
$request->header('content-length' => $len);
 ...

--
Charles DeRykus


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

Date: Thu, 23 Oct 2008 16:23:56 -0700 (PDT)
From: clearguy02@yahoo.com
Subject: Comparison of two files..
Message-Id: <f9bc7a7e-e609-440e-aaa6-ed7e9f41a5a5@c22g2000prc.googlegroups.com>

Hi folks,

I have two files:
 a.txt has 100 unique log_id's (one id per line);
 all.txt has 5000 entries (each line has six entries seperated by a
tab and the first entry on each line is the login ID and then full
name, country etc).

Now I want to match both files and get the output with all 100 full
entries and ignore the rest.

Here is the code I am working on.. for some reason, I see more 160
entries instead of the exact 100 entries.

++++++++++++++++++++
my %myconfig = (
    input1      => 'a.txt',
    input2       => 'all.txt',
    matching     => 'required.txt',
    non_matching => 'ignore.txt',
);

my %fields2;
{
    open my $input, '<', $myconfig{input1}  or die "Cannot open
'$myconfig{input1}': $!";
    while ( <$input> )
     {
        if ( /^(\w+)/ )
         {
            $fields2{ $1 } = 1;
         }
     }
    close $input or die "Cannot close '$myconfig{input1}': $!";
}
open my $input, '<', $myconfig{input2}   or die "Cannot open
'$myconfig{input2}': $!";
open my $matching, '>', $myconfig{matching}     or die "Cannot open
'$myconfig{matching}': $!";
open my $non_matching, '>', $myconfig{non_matching}     or die "Cannot
open '$myconfig{non_matching}': $!";

while ( <$input> )
{
    if ( /^(\w+)/ )
    {
        if ( exists $fields2{ $1 } )
        {
            print $matching "$_\n";
        }
        else
        {
            print $non_matching  "$_\n";
        }
    }
 }

++++++++++++++++++++++++++++++++++++

What I am doing wrong here? Or is there any alternative way of doing
it?

Thanks,
J


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

Date: Thu, 23 Oct 2008 12:53:54 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Connect to MS SQL 2005 server from UNIX
Message-Id: <2d19f2ce-f2a6-4ea0-ba01-3cb43bc53066@o40g2000prn.googlegroups.com>

Hi,

I'm trying to connect to MS SQL 2005 server from UNIX. But I get the
warning below.

I can connect through C#.NET fine using the same server, user &
password.
Any idea why?

Here's the perl code:

#!/usr/local/bin/perl

use strict;
use warnings;

use DBI;

my $server = "xxx";
my $user = "xxx";
my $password = "xxx";
my $dbname = "xxx";


my @available_drivers = DBI->available_drivers;
print ("The available DBD drivers are: @available_drivers.\n");

my $dbh = DBI->connect("dbi:Sybase:$server", "$user", "$password")
      or die "Cannot log into $server\n";



login> perl testSQL.pl
The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.
src/tds/login.c: tds_connect: x.x.x.x:4000: Connection refused
DBI connect('xxx','xxx',...) failed: OpenClient message: LAYER = (0)
ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
Server xxx, database
Message String: Server is unavailable or does not exist. at testSQL.pl
line 17
Cannot log into xxx


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

Date: Thu, 23 Oct 2008 15:37:24 -0700 (PDT)
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: Connect to MS SQL 2005 server from UNIX
Message-Id: <f821a766-426b-4d25-a3ac-64e494b9637b@26g2000hsk.googlegroups.com>

On Oct 23, 2:53=A0pm, Slickuser <slick.us...@gmail.com> wrote:
<snip>
>
> login> perl testSQL.pl
> The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
> Sponge Sybase mysql.
> src/tds/login.c: tds_connect: x.x.x.x:4000: Connection refused
> DBI connect('xxx','xxx',...) failed: OpenClient message: LAYER =3D (0)
> ORIGIN =3D (0) SEVERITY =3D (78) NUMBER =3D (41)
> Server xxx, database
> Message String: Server is unavailable or does not exist. at testSQL.pl
> line 17
> Cannot log into xxx

This isn't really a Perl question, since the problem you're having is
with the connection to your database.

If I were getting this problem, the first thing I'd check is that port
4000. Is that the correct port?
I'd also look at my Sybase docs and try and determine what the LAYER,
ORIGIN, SEVERITY, NUMBER messages meant.

Hope that helps, but you probably want to be talking to some Sybase
people about this issue, not Perl


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

Date: 23 Oct 2008 15:34:25 GMT
From: xhoster@gmail.com
Subject: Re: Filehandle STDIN reopened as $fh1 only for output
Message-Id: <20081023113451.434$Rc@newsreader.com>

Tad J McClellan <tadmc@seesig.invalid> wrote:
>
> Let's see what perldiag says about that message:
>
>     =item Filehandle STDIN reopened as %s only for output
>
>     (W io) You opened for writing a filehandle that got the same
>     filehandle id as STDIN. This occurred because you closed STDIN
>     previously.

But that is a pretty useless explanation.  OK, so some file handle got
opened to some file descriptor.  So what?  Why should I care?  What is
likely to happen?  If there is some danger, what is it?  If not, then why
warn me?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Thu, 23 Oct 2008 16:33:50 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Filehandle STDIN reopened as $fh1 only for output
Message-Id: <slrngg0v9v.eao.whynot@orphan.zombinet>

On 2008-10-23, Larry <dontmewithme@got.it> wrote:
> I have the following code:
*SKIP*
>    close(STDIN);
*SKIP*
>       {open my $fh1, '<', $pswdfile or die "$pswdfile $!";undef 
*SKIP*
>       open my $fh1, ">", $pswdfile or die "$!";
*SKIP*
> it fires thi error/warn: "Filehandle STDIN reopened as $fh1 only for 
> output"
>
> this seems to happen when it encounters this: open my $fh1, ">", 
> $pswdfile or die "$!";
>
> what am I actually doing wrong?

When you've closed I<STDIN> it become unused (IOW -- free).  The 2nd
time you open it for reading -- it's OK.  The 3rd time you open it for
writing.  B<open(2)> picks whatever filehandle is free -- accidentally
it's filehandle number 0 (it's I<STDIN>).

You have an option -- ether ignore the warning or do it this way
C<open STDIN, '<', '/dev/null' or die "$!";> in first place.

-- 
Torvalds' goal for Linux is very simple: World Domination


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

Date: Thu, 23 Oct 2008 18:53:34 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Filehandle STDIN reopened as $fh1 only for output
Message-Id: <gdqh7e$u31$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Eric Pozharski 
<whynot@pozharski.name>], who wrote in article <slrngg0v9v.eao.whynot@orphan.zombinet>:

Just in case: I think the (correct) explanation below needs some minor
clarification.

> When you've closed I<STDIN> it become unused (IOW -- free).  The 2nd
                                                               ^^^^^^^
> time you open it for reading -- it's OK.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The 1st time you open A FILE for reading, the OS looks for the first
unused handle.  Since STDIN is handle 0, and it is unused, OS choses
to open a new file as handle 0.  So, effectively you reopen STDIN.

Then you close it again...

>  The 3rd time you open it for writing.  B<open(2)> picks whatever
> filehandle is free -- accidentally it's filehandle number 0 (it's I<STDIN>).

Likewise:

The 2nd time you open A FILE for writing, OS (again!) chooses the
first unused handle, so get handle 0 again.  This time Perl detects
that STDIN is opened for write, and decides to warn().

This time Perl heuristic is wrong, and this warning is not relevant.
You can selectively disable it, as another poster recommends.

> You have an option -- ether ignore the warning or do it this way
> C<open STDIN, '<', '/dev/null' or die "$!";> in first place.

Hope this helps,
Ilya


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

Date: Thu, 23 Oct 2008 08:13:46 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Fine tuning appearance of charts produced by Chart::Lines: is it  possible?
Message-Id: <357b894e-6594-4bcb-b495-458c8f2c266d@y21g2000hsf.googlegroups.com>

I have been searching through the documentation for Chart::Lines to no
avail.  What I am looking for is a way to have the chart format  the
tick labels for the Y axis.  In one case, I need to append the '%'
symbol to the number displyed, whatever that number is, and in another
I need to prepend the "$" to the number.  Not only do I have functions
that do this to output I send to a file, or into a PDF::Table, I have
a function that inserts ',' into numbers greather than or equal to
1,000, to make such numbers easier to read.

How can I tell Chart::Lines to use a particular format, or, better, to
use one of my functions, to format the tick labels?

Thanks

Ted


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

Date: 23 Oct 2008 22:22:59 GMT
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Is it possible to store an SV in C pointer
Message-Id: <4900f943$0$193$e4fe514c@news.xs4all.nl>

On Thu, 23 Oct 2008 03:21:03 -0700, cyl wrote:
> In my Perl script, that SV exists in the entire scope so it should not
> be collected, shouldn't it? For example,
> 
> my $ref = [1,2,3];
> 
> funcA($ref);
> funcB(); # which uses the pointer p to access $ref 
> __END__
> 
> This is my assumption but it seems the address I saved is not permanent.

The address doesn't change. The address you have is $ref. Though I'm 
wondering why you would store it in a void* when you can store it in a 
SV*.

> I'm wondering what is the correct way to get the permanent address of
> $ref in C. I tried SvIV, SvRV, SvPV and other APIs that I have no clue
> what they are actually but all are in vain.

In that case you should definitely reread perlapi and perlguts and make 
sure you understand that all. In this case, the return value of SvRV will 
be the array (though you will need to cast it to an AV* to use it).

> Should I increase the refcount if I'm sure it exists on the entire
> scope?

If you're absolutely sure it will exist you can leave it, but increasing/
decreasing it would be good form IMHO.

Regards.

Leon Timmermans


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

Date: Thu, 23 Oct 2008 18:04:12 -0700 (PDT)
From: cyl <u8526505@gmail.com>
Subject: Re: Is it possible to store an SV in C pointer
Message-Id: <6fc50a7c-bf81-400b-bbd9-ee900b457788@n33g2000pri.googlegroups.com>

On 10$B7n(B24$BF|(B, $B>e8a(B6$B;~(B22$BJ,(B, Leon Timmermans <faw...@gmail.com> wrote:
> > my $ref = [1,2,3];
>
> > funcA($ref);
> > funcB(); # which uses the pointer p to access $ref
> > __END__
>
> The address doesn't change. The address you have is $ref. Though I'm
> wondering why you would store it in a void* when you can store it in a
> SV*.
>
But the value is changed when I access the address in funcB. In funcA,
SvROK(ST(0)) returns true while in funcB,  calling SvROK with the same
address returns false. The value has been changed at that address.
That's why I suspect it is not permanent and wonder the correct
method.



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

Date: Thu, 23 Oct 2008 15:03:30 -0700
From: David Filmer <usenet@davidfilmer.com>
Subject: Re: question about data structures - what does $# mean?
Message-Id: <Bb2dnSEpUooAaZ3U4p2dnAA@giganews.com>

Ed wrote:

> So to get the number of elements in the array I try:
> $#{$d->{sid}}
> But that does not work. It gives me 0.

$# gives you the highest INDEX number of an array.  This array has one 
item in it, so the highest index is zero (because arrays begin numbering 
at zero).

If you want to find out how many elements are in the array you can use 
the array variable in scalar context, or force scalar context with 
scalar(), ie:

    print scalar @{$d->{sid}};


-- 
David Filmer (http://DavidFilmer.com)
The best way to get a good answer is to ask a good question.


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

Date: Thu, 23 Oct 2008 23:14:32 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Question on the length of a Scalar
Message-Id: <gdr0k4.15c.1@news.isolution.nl>

Jürgen Exner schreef:
>> sln:

>>> When I call the length function on a scalar, is it read directly
>>> (ie: already know its length), or does it traverse the string
>>> counting its characters until it hits a nul terminator?
>
> Neither, nor.
> First the string representation of that scalar is computed, then the
> length of that string representation returned.

s/(?<=computed)/ or selected/

(because the string representation can already be available)

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Thu, 23 Oct 2008 11:16:46 -0700 (PDT)
From: Grega <grega@kt.agh.edu.pl>
Subject: Script for uploading files to a server
Message-Id: <496da7ab-105b-475c-bd90-f131630ac3ea@l62g2000hse.googlegroups.com>

Hi!

I use the following script for saving the uploaded file to the server.
It is basically driving me mad!
($q is initialised before)

    my $sourceFilePath = $q->param('pdf');
    my $fileHandle = $q->upload('pdf');
    open (OUT, ">test.pdf") or die "$!";
    binmode OUT;
    while(<$fileHandle>){
        print OUT;
    }
    close OUT;


What is the basic problem - $fileHandle seems to be empty while
$sourceFilePath holds the correct filename! I am stuck with this
problem for some time now :/

I have the current version of the CGI module.

Thank you in advance!


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

Date: Thu, 23 Oct 2008 20:34:35 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Script for uploading files to a server
Message-Id: <87iqrj9n44.fsf@zeekat.nl>

Grega <grega@kt.agh.edu.pl> writes:


> What is the basic problem - $fileHandle seems to be empty while
> $sourceFilePath holds the correct filename! I am stuck with this
> problem for some time now :/

99% chance you're not using <form enctype="multipart/form-data">

See http://www.w3.org/TR/html401/interact/forms.html#h-17.3

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


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

Date: Thu, 23 Oct 2008 13:17:08 -0700 (PDT)
From: Grega <grega@kt.agh.edu.pl>
Subject: Re: Script for uploading files to a server
Message-Id: <ad1cb4d3-cb83-45be-837a-426afc3a602c@17g2000hsk.googlegroups.com>

> 99% chance you're not using <form enctype="multipart/form-data">
>
> Seehttp://www.w3.org/TR/html401/interact/forms.html#h-17.3
>

IT WORKED!

You cannot imagine how grateful I am. To my assumptions I spend ~20
hours solving this simple bug :/
The whole problem is, that I am editing a web service written a long
time ago by someone else..

Thanks again!


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

Date: Thu, 23 Oct 2008 14:21:25 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Unix, Perl, IE, and Excel
Message-Id: <2b65ae05-df8a-41f7-b727-4f993f2261e1@f63g2000hsf.googlegroups.com>

Here is a question that I guess I should know the answer to, but I
don't. I have a large (7,000 by 9) dataset that I need make available
to users through a browser.

This isn't difficult: I open the file, construct a hash of the index,
put the hash keys in an <select> element, allow the users to select
the keys they want, and spit out those records in html. Some users
want to download the data, so I allow users to either print the data
to their local printer or download a subset of the dataset constructed
on the fly.

Here's the question: I have a user who wants the data embedded in an
Excel worksheet right on the web page. Can this be done? The web
server is Apache coming from Linux, but Userland is 100% Windows.

TIA, CC.


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

Date: Thu, 23 Oct 2008 15:06:02 -0700
From: David Filmer <usenet@davidfilmer.com>
Subject: Re: Unix, Perl, IE, and Excel
Message-Id: <Bb2dnSApUoqoaJ3U4p2dnAA@giganews.com>

cartercc wrote:
> <snip WAAAAYYYYY off-topic question>

Greetings.  This is a Perl programming newsgroup.  You should post your 
question in a newsgroup where folks might be able to help you out.


-- 
David Filmer (http://DavidFilmer.com)
The best way to get a good answer is to ask a good question.


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

Date: Thu, 23 Oct 2008 17:13:11 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Unix, Perl, IE, and Excel
Message-Id: <4900f6f8$0$48226$815e3792@news.qwest.net>

cartercc wrote:
[...]
> Here's the question: I have a user who wants the data embedded in an
> Excel worksheet right on the web page. Can this be done? The web
> server is Apache coming from Linux, but Userland is 100% Windows.

Here's an even better question. What does this have to do with Perl?

If you use your favorite Internet search engine and look for 'embed 
excel' you'd have found possible solutions.  e.g. <iframe>, <object>, ...


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

Date: Thu, 23 Oct 2008 16:06:59 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: Unix, Perl, IE, and Excel
Message-Id: <7b6b56bd-18a3-4388-8850-130767887595@79g2000hsk.googlegroups.com>

On Oct 23, 6:13=A0pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:

> Here's an even better question. What does this have to do with Perl?

I'm using Perl as the programming language to build the app. I use
Perl to construct PDFs, RTFs, XMLs, and other kinds of documents. I
also use Perl to build files that open natively in Excel, such as
CSVs. I was thinking that I could construct a file with Perl in a
format that could be downloaded via an http request that the browser
would recognize and open in the appropriate application, like MIDI,
MP3, swf, and so on. Does this have nothing to do with Perl?

> If you use your favorite Internet search engine and look for 'embed
> excel' you'd have found possible solutions. =A0e.g. <iframe>, <object>, .=
 ..

I did. I routinely use iframes to display non-HTML documents such
as .txt files, so I tried that first, then the object element, and I
found some applets that pretty closely mimic Excel. I've about
concluded that this is impossible except with the Microsoft publishing
Excel as a web service, which I can't do unless I use a Windows
server.

CC


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

Date: Thu, 23 Oct 2008 23:35:13 +0000 (UTC)
From: INVALID_SEE_SIG@example.com.invalid (J.D. Baldwin)
Subject: Re: Unix, Perl, IE, and Excel
Message-Id: <gdr1nh$j3v$1@reader1.panix.com>


In the previous article, cartercc  <cartercc@gmail.com> wrote:
> Here's the question: I have a user who wants the data embedded in an
> Excel worksheet right on the web page. Can this be done? The web
> server is Apache coming from Linux, but Userland is 100% Windows.

I have been mailing Perl-built Excel spreadsheets for some years with
the excellent Spreadseet::WriteExcel, about which you can read more at

    http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm
-- 
  _+_ From the catapult of |If anyone objects to any statement I make, I am
_|70|___:)=}- J.D. Baldwin |quite prepared not only to retract it, but also
\      /  baldwin@panix.com|to deny under oath that I ever made it.-T. Lehrer
***~~~~----------------------------------------------------------------------


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

Date: Fri, 24 Oct 2008 02:11:20 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: Unix, Perl, IE, and Excel
Message-Id: <gdr3v9$u34$2@aioe.org>

cartercc wrote:
> Here's the question: I have a user who wants the data embedded in an
> Excel worksheet right on the web page. Can this be done? The web
> server is Apache coming from Linux, but Userland is 100% Windows.
>

You can use two Perl modules. Spreadseet::WriteExcel or Text::CSV. For MS-EXcel 
you can use a old but simple trick. Create standard *.csv file but change file 
extension to *.xls :-)
-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Thu, 23 Oct 2008 12:18:01 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: Where is the documentation to show how to add a PNG file to a PDF
Message-Id: <00788386-3243-4985-89f8-a5c5034983ac@d1g2000hsg.googlegroups.com>

On Oct 23, 2:36=A0pm, Christian Winter <thepoet_nos...@arcor.de> wrote:
> Ted Byers wrote:
> > Thanks Chris. =A0That is helpful. =A0But now it appears that $gfx (I'd
> > guesed that $gfx, which I've seen a lot, was a canvas, but I have yet
> > to find the documentation of its interface) needs data that chart
> > doesn't appear to put into the png files it makes. =A0For example, $gfx=
-
> >> image wants a height and width function/data member (which isn't
> > clear to me yet), the the image object returned by
> > 'image_png("chart1.png");' doesn't have that. Providing a desired
> > width and height solves that, but then I find $gfx->image wants a name
> > from that object, and it isn't clear what that ought to be, what it is
> > used for, or how I can set it. =A0There doesn't seem to be a way to pas=
s
> > an arbitrary name =A0as an argument. =A0So I am lost as to what to do. =
=A0I
> > don't know if the deficiency is in the png file my code produces using
> > Chart (these images are easily opened, without problems, by each of
> > the graphics packages I use for image editing), or if it is in how I
> > am using $gfx->image so far.
>
> When the image method dies and calls for a name, it's usually due
> to the passed variable not being a valid image object as returned
> by the $pdf->image_* methods (probably a typo). PNGs created by
> the Chart modules do work with PDF::API2. I've put together a
> small test script that produces the desired output here:
> ###############################################################
> #!/usr/bin/perl
>
> use Chart::Lines;
> use PDF::API2;
> use strict;
> use warnings;
>
> # Chart Creation
>
> my @data =3D ([1999,2000,2001,2002],[1234,2344,3544,2345]);
>
> my $chart =3D Chart::Lines->new( 500, 300 );
> # The tick formatter you've asked for in your other message:
> $chart->set( 'f_x_tick' =3D> \&years );
>
> $chart->png( "test.png", \@data );
>
> sub years {
> =A0 =A0 =A0 =A0 return "Yr " . shift;
>
> }
>
> # PDF Creation
>
> my $pdf =3D PDF::API2->new();
> $pdf->mediabox("A4");
>
> my $fnt =3D $pdf->corefont('Helvetica-Bold');
>
> my $page =3D $pdf->page;
>
> my $gfx =3D $page->gfx;
>
> $gfx->textlabel( 200, 750, $fnt, 20, "Chart PNGs Work!" );
>
> my $img =3D $pdf->image_png( "test.png" );
> $gfx->image( $img, 50, 400, 500, 300 );
>
> $pdf->saveas( "test.pdf" );
> __END__
> ###############################################################
>
> -Chris- Hide quoted text -
>
> - Show quoted text -

As Chris shows here, making a pdf is a step by step procedure that
builds on previous ones.

1st you make the "template":

my $pdf =3D PDF::API2->new();

Then you set the size of the pdf:

$pdf->mediabox("A4");

Then you add a page to the pdf:

my $page =3D $pdf->page;

Then you add a graphic "template" to the page:

my $gfx =3D $page->gfx;

Then you "load" the image:

my $img =3D $pdf->image_png( "test.png" );

And then apply this image to the graphic "template":

$gfx->image( $img, 50, 400, 500, 300 );

If you were making multiple, pages, you could now do another add page
and do things with it.

When you are finally done you save the pdf:

$pdf->saveas( "test.pdf" );

I work with PDF::API2 every day. It ia very powerful module if you
understand how it works.

Bill H


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

Date: Thu, 23 Oct 2008 20:36:19 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Where is the documentation to show how to add a PNG file to a PDF
Message-Id: <4900c406$0$17378$9b4e6d93@newsspool1.arcor-online.net>

Ted Byers wrote:
> Thanks Chris.  That is helpful.  But now it appears that $gfx (I'd
> guesed that $gfx, which I've seen a lot, was a canvas, but I have yet
> to find the documentation of its interface) needs data that chart
> doesn't appear to put into the png files it makes.  For example, $gfx-
>> image wants a height and width function/data member (which isn't
> clear to me yet), the the image object returned by
> 'image_png("chart1.png");' doesn't have that. Providing a desired
> width and height solves that, but then I find $gfx->image wants a name
> from that object, and it isn't clear what that ought to be, what it is
> used for, or how I can set it.  There doesn't seem to be a way to pass
> an arbitrary name  as an argument.  So I am lost as to what to do.  I
> don't know if the deficiency is in the png file my code produces using
> Chart (these images are easily opened, without problems, by each of
> the graphics packages I use for image editing), or if it is in how I
> am using $gfx->image so far.

When the image method dies and calls for a name, it's usually due
to the passed variable not being a valid image object as returned
by the $pdf->image_* methods (probably a typo). PNGs created by
the Chart modules do work with PDF::API2. I've put together a
small test script that produces the desired output here:
###############################################################
#!/usr/bin/perl

use Chart::Lines;
use PDF::API2;
use strict;
use warnings;

# Chart Creation

my @data = ([1999,2000,2001,2002],[1234,2344,3544,2345]);

my $chart = Chart::Lines->new( 500, 300 );
# The tick formatter you've asked for in your other message:
$chart->set( 'f_x_tick' => \&years );

$chart->png( "test.png", \@data );

sub years {
	return "Yr " . shift;
}

# PDF Creation

my $pdf = PDF::API2->new();
$pdf->mediabox("A4");

my $fnt = $pdf->corefont('Helvetica-Bold');

my $page = $pdf->page;

my $gfx = $page->gfx;

$gfx->textlabel( 200, 750, $fnt, 20, "Chart PNGs Work!" );

my $img = $pdf->image_png( "test.png" );
$gfx->image( $img, 50, 400, 500, 300 );

$pdf->saveas( "test.pdf" );
__END__
###############################################################

-Chris


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

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 1942
***************************************


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