[30696] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1941 Volume: 11

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

Date: Thu, 23 Oct 2008 08:09:07 -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: 1941

Today's topics:
        Filehandle STDIN reopened as $fh1 only for output <dontmewithme@got.it>
    Re: Filehandle STDIN reopened as $fh1 only for output <tadmc@seesig.invalid>
    Re: Filehandle STDIN reopened as $fh1 only for output <ced@blv-sam-01.ca.boeing.com>
        Format for data exchange? <setesting001@gmail.com>
        Is it possible to store an SV in C pointer <u8526505@gmail.com>
    Re: Is it possible to store an SV in C pointer <joost@zeekat.nl>
    Re: Is it possible to store an SV in C pointer <u8526505@gmail.com>
    Re: Need help with a REGEX <tadmc@seesig.invalid>
        new CPAN modules on Thu Oct 23 2008 (Randal Schwartz)
    Re: Where is the documentation to show how to add a PNG <r.ted.byers@gmail.com>
    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 10:02:05 +0200
From: Larry <dontmewithme@got.it>
Subject: Filehandle STDIN reopened as $fh1 only for output
Message-Id: <dontmewithme-5EF6AC.10020423102008@news.tin.it>

I have the following code:

open STDERR, ">>", ".log.txt";

if ( $ENV{"REQUEST_METHOD"} eq 'HEAD' )
{
   close(STDIN);
   if($ENV{"HTTP_USER_AGENT"})
   {
      if(&_check_header_password($ENV{"HTTP_USER_AGENT"}))
      {
         print "Status: 200 OK\n\n";
      } else {
         print "Status: 401 Wrong Password\n\n";
      }
   }
   exit;
 }

sub _check_header_password
{
   my $pswd     = shift;
   my $pswdfile = '_pswd.txt';
   my $header_pswd; ($header_pswd) = ($pswd =~ /<pwd>(.*?)<\/pwd>/sg);
   
   if (-e $pswdfile)
   {
      my $savedpswd;
      {open my $fh1, '<', $pswdfile or die "$pswdfile $!";undef 
$/;$savedpswd = <$fh1>;close $fh1;};
      if ($header_pswd eq $savedpswd) { return 1; } else { return 0; }
   } else {
      open my $fh1, ">", $pswdfile or die "$!";
      print $fh1 $header_pswd;
      close $fh1;
      return 1;
   }
 }
__END__;

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?

thanks


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

Date: Thu, 23 Oct 2008 07:43:45 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Filehandle STDIN reopened as $fh1 only for output
Message-Id: <slrngg0sc1.tro.tadmc@tadmc30.sbcglobal.net>

Larry <dontmewithme@got.it> wrote:

>    close(STDIN);
>    if($ENV{"HTTP_USER_AGENT"})
>    {
>       if(&_check_header_password($ENV{"HTTP_USER_AGENT"}))


You should not use an ampersand of subroutine calls unless you know
what it does (perlsub.pod), and what it does is what you want (it seldom is):

    if( _check_header_password($ENV{HTTP_USER_AGENT}) )


>    my $header_pswd; ($header_pswd) = ($pswd =~ /<pwd>(.*?)<\/pwd>/sg);


No need for 2 statements when 1 statement will do:

    my($header_pswd) = ($pswd =~ /<pwd>(.*?)<\/pwd>/sg);


>    if (-e $pswdfile)


Warning Will Robinson!

You are introducing a race condition...

   perldoc -q lock

       Why can't I just open(FH, "E<gt>file.lock")?


>       open my $fh1, ">", $pswdfile or die "$!";


> it fires thi error/warn: 


All of perl's diagnostic messages are described in perldiag.pod,
where you can see that it is a warning message rather than an
error message.


> "Filehandle STDIN reopened as $fh1 only for 
> output"


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.


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


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

Date: Thu, 23 Oct 2008 06:22:11 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Filehandle STDIN reopened as $fh1 only for output
Message-Id: <ffaf6d7d-416f-455f-b2e6-0805f73767d4@s9g2000prm.googlegroups.com>

On Oct 23, 1:02 am, Larry <dontmewit...@got.it> wrote:
> I have the following code:
>
> open STDERR, ">>", ".log.txt";
>
> if ( $ENV{"REQUEST_METHOD"} eq 'HEAD' )
> {
>    close(STDIN);
>    if($ENV{"HTTP_USER_AGENT"})
>    {
>       if(&_check_header_password($ENV{"HTTP_USER_AGENT"}))
>       {
>          print "Status: 200 OK\n\n";
>       } else {
>          print "Status: 401 Wrong Password\n\n";
>       }
>    }
>    exit;
>  }
>
> sub _check_header_password
> {
>    my $pswd     = shift;
>    my $pswdfile = '_pswd.txt';
>    my $header_pswd; ($header_pswd) = ($pswd =~ /<pwd>(.*?)<\/pwd>/sg);
>
>    if (-e $pswdfile)
>    {
>       my $savedpswd;
>       {open my $fh1, '<', $pswdfile or die "$pswdfile $!";undef
> $/;$savedpswd = <$fh1>;close $fh1;};
>       if ($header_pswd eq $savedpswd) { return 1; } else { return 0; }
>    } else {
>       open my $fh1, ">", $pswdfile or die "$!";
>       print $fh1 $header_pswd;
>       close $fh1;
>       return 1;
>    }
>  }
> __END__;
>
> 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?
>

This is just a warning that an unusual
write-only  tweak has been made to STDIN.

$ perl -Mdiagnostics -w
close STDIN;open(my $fh, ">",undef)
^D

Filehandle STDIN reopened as $fh only for output at - line 1 (#1)
    (W io) You opened for writing a filehandle that got the same
filehandle id
    as STDIN. This occured because you closed STDIN previously.


You could suppress the warning by
opening the file for both read/write
for instance (perldoc -f open).

Also you sure though you need this kind of
"Do It Yourself" password handling...

--
Charles DeRykus


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

Date: Thu, 23 Oct 2008 07:17:44 -0700 (PDT)
From: Roy M <setesting001@gmail.com>
Subject: Format for data exchange?
Message-Id: <f1505bbc-a14f-412d-9425-230d5d0f1451@d10g2000pra.googlegroups.com>

Hello all,

We are using XMLRPC to communicate between servers (cross languages
with PHP and Java)  for many years.

Seems nowadays better choices would be YAML, JSON or even Google
protocol buffer?

Which format your are using, and why?


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

Date: Thu, 23 Oct 2008 00:29:16 -0700 (PDT)
From: cyl <u8526505@gmail.com>
Subject: Is it possible to store an SV in C pointer
Message-Id: <ffb80490-501a-4a6c-a37b-fcff23177574@i18g2000prf.googlegroups.com>

Suppose I have two functions in my XS code, say funcA and funcB, after
I store an SV in a global pointer in funcA, is it possible for me to
access it in funcB? Here is my pseudo code

void *p;

void funcA()
{
      p = (void*)ST(0); //suppose ST(0) is a reference
}

void funcB()
{
      SV *sv = (SV*)p;
      if (SvROK(sv)) ...     //actually I cannot get the original SV
in funcA
}

What is the correct way? Thanks.


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

Date: Thu, 23 Oct 2008 11:06:59 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Is it possible to store an SV in C pointer
Message-Id: <87hc73bryk.fsf@zeekat.nl>

cyl <u8526505@gmail.com> writes:

> Suppose I have two functions in my XS code, say funcA and funcB, after
> I store an SV in a global pointer in funcA, is it possible for me to
> access it in funcB?

Yes.

> Here is my pseudo code
>
> void *p;
>
> void funcA()
> {
>       p = (void*)ST(0); //suppose ST(0) is a reference

Better make sure it is, if that's what you're using to test it...

> }
>
> void funcB()
> {
>       SV *sv = (SV*)p;
>       if (SvROK(sv)) ...     //actually I cannot get the original SV
> in funcA
> }

Unless you're calling funcB from funcA, it's possible that the SV gets
collected after funcA() returns to perl and before funcB() gets called.

You should at least make sure you increase p's refcount when you store
it, and decrease it whenever you remove your reference to it.

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


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

Date: Thu, 23 Oct 2008 03:21:03 -0700 (PDT)
From: cyl <u8526505@gmail.com>
Subject: Re: Is it possible to store an SV in C pointer
Message-Id: <49dd6841-f6c0-4d76-83d2-df6382484611@c36g2000prc.googlegroups.com>

On 10$B7n(B23$BF|(B, $B2<8a(B5$B;~(B06$BJ,(B, Joost Diepenmaat <jo...@zeekat.nl> wrote:

>
> Unless you're calling funcB from funcA, it's possible that the SV gets
> collected after funcA() returns to perl and before funcB() gets called.
>
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. 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.


> You should at least make sure you increase p's refcount when you store
> it, and decrease it whenever you remove your reference to it.
>
Should I increase the refcount if I'm sure it exists on the entire
scope?


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

Date: Thu, 23 Oct 2008 06:56:16 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Need help with a REGEX
Message-Id: <slrngg0pj0.tro.tadmc@tadmc30.sbcglobal.net>

Michael R. McPherson Pierotti <mike.pierotti@docomopacific.net> wrote:
> Folks its been awhile (5 years) since I have done anything with Perl so I
> consider myself back at newbie statis :(

> $t = new Net::Telnet (Timeout => 10,Prompt => '/\</' ); #


Angle brackets are not regex metacharacters, so there is no
need to escape them.

Using the "Indirect Object Syntax" (perlobj.pod) is a Bad Idea, 
so that would be better written as:

    $t = Net::Telnet->new(Timeout => 10,Prompt => '/</' );


> $n=0;
> while ($RIR[$n]) {
>  if ($RIR[$n] =~ m/^TREE/){
>   $line = $RIR[$n];
>   $line =~ /\d/;
>   print $line . "\n";
>  }
> $n++;
> }


One-character indents is a really poor style choice...


> Now my problem is this. The Net::Telnet command fills my array with lines
> like the following
>
> TREE=  950  ATYPE=N  TON=INT


> Now want I want to do is a REGEX to pull ONLY the digits out of this (950)
> and assign them to s $string.


You should let perl do the array indexing for you, by using a foreach
instead of a while with a counter.

Using m// in a scalar context:

    foreach my $line ( @RIR ) {
        if ( $line =~ m/^TREE=\s+(\d+)/ ) {
            $string = $1;
            print "$string\n";
        }
    }

Or, using m// in a list context:

    foreach my $line ( @RIR ) {
        my($string) = $line =~ m/^TREE=\s+(\d+)/;
        print "$string\n" if defined $string;
    }


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


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

Date: Thu, 23 Oct 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Oct 23 2008
Message-Id: <K96D2M.Mys@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Algorithm-Diff-XS-0.01
http://search.cpan.org/~audreyt/Algorithm-Diff-XS-0.01/
Algorithm::Diff with XS core loop 
----
Algorithm-Munkres-0.08
http://search.cpan.org/~tpederse/Algorithm-Munkres-0.08/
Perl extension for Munkres' solution to classical Assignment problem for square and rectangular matrices This module extends the solution of Assignment problem for square matrices to rectangular matri
----
Apache2-ASP-2.00_06
http://search.cpan.org/~johnd/Apache2-ASP-2.00_06/
ASP for Perl, reloaded. 
----
App-Hachero-0.03
http://search.cpan.org/~danjou/App-Hachero-0.03/
a plaggable log analyzing framework 
----
App-Test-Tapat-0.02
http://search.cpan.org/~jeremiah/App-Test-Tapat-0.02/
A testing framework 
----
Attribute-Storage-0.01
http://search.cpan.org/~pevans/Attribute-Storage-0.01/
store and access named attributes about CODE references 
----
B-Hooks-Parser-0.02
http://search.cpan.org/~flora/B-Hooks-Parser-0.02/
Interface to perls parser variables 
----
Business-DPD-0.10
http://search.cpan.org/~domm/Business-DPD-0.10/
handle DPD lable generation 
----
CPAN-Mini-Inject-0.22
http://search.cpan.org/~ssoriche/CPAN-Mini-Inject-0.22/
Inject modules into a CPAN::Mini mirror. 
----
Catalyst-Authentication-Store-FromSub-Hash-0.09
http://search.cpan.org/~fayland/Catalyst-Authentication-Store-FromSub-Hash-0.09/
A storage class for Catalyst Authentication using one Catalyst Model class (hash returned) 
----
Coro-4.801
http://search.cpan.org/~mlehmann/Coro-4.801/
coroutine process abstraction 
----
Crypt-NSS-0.04
http://search.cpan.org/~claesjac/Crypt-NSS-0.04/
Perl bindings to NSS (Netscape Security Services) 
----
DBIx-Class-InflateColumn-Boolean-0.001001
http://search.cpan.org/~graf/DBIx-Class-InflateColumn-Boolean-0.001001/
Auto-create boolean objects from columns. 
----
Devel-CheckOS-1.45
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.45/
check what OS we're running on 
----
Exception-Class-1.25
http://search.cpan.org/~drolsky/Exception-Class-1.25/
A module that allows you to declare real exception classes in Perl 
----
File-Find-Object-0.1.1
http://search.cpan.org/~shlomif/File-Find-Object-0.1.1/
An object oriented File::Find replacement 
----
Games-Risk-2.0.3
http://search.cpan.org/~jquelin/Games-Risk-2.0.3/
classical 'risk' board game 
----
Gnaw-0.07
http://search.cpan.org/~gslondon/Gnaw-0.07/
Define parse grammars using perl subroutine calls. No intermediate grammar languages. 
----
Google-ProtocolBuffers-0.06
http://search.cpan.org/~gariev/Google-ProtocolBuffers-0.06/
simple interface to Google Protocol Buffers 
----
HTTP-Session-0.01_01
http://search.cpan.org/~tokuhirom/HTTP-Session-0.01_01/
simple session 
----
HTTP-Session-0.01_02
http://search.cpan.org/~tokuhirom/HTTP-Session-0.01_02/
simple session 
----
HTTP-Session-0.01_03
http://search.cpan.org/~tokuhirom/HTTP-Session-0.01_03/
simple session 
----
HTTP-Session-0.01_04
http://search.cpan.org/~tokuhirom/HTTP-Session-0.01_04/
simple session 
----
IO-AIO-3.16
http://search.cpan.org/~mlehmann/IO-AIO-3.16/
Asynchronous Input/Output 
----
IPC-SRLock-0.1.78
http://search.cpan.org/~pjfl/IPC-SRLock-0.1.78/
Set/reset locking semantics to single thread processes 
----
Lingua-JA-Expand-0.00002
http://search.cpan.org/~miki/Lingua-JA-Expand-0.00002/
word expander by associatives 
----
List-Rubyish-0.03
http://search.cpan.org/~yappo/List-Rubyish-0.03/
Array iterator like the Ruby 
----
Mail-Postfix-Postdrop-0.1
http://search.cpan.org/~pmakholm/Mail-Postfix-Postdrop-0.1/
Inject mails to a Postfix maildrop directory 
----
Math-GSL-0.14
http://search.cpan.org/~leto/Math-GSL-0.14/
Perl interface to the GNU Scientific Library (GSL) 
----
Method-Signatures-20081021.1911
http://search.cpan.org/~mschwern/Method-Signatures-20081021.1911/
method declarations with signatures and no source filter 
----
Module-Collect-0.05
http://search.cpan.org/~yappo/Module-Collect-0.05/
module files are collected from some directories 
----
Module-Install-ExtraTests-0.004
http://search.cpan.org/~rjbs/Module-Install-ExtraTests-0.004/
contextual tests that the harness can ignore 
----
Module-Setup-0.05
http://search.cpan.org/~yappo/Module-Setup-0.05/
a simple module maker "yet another Module::Start(?:er)?" 
----
Module-Setup-0.06
http://search.cpan.org/~yappo/Module-Setup-0.06/
a simple module maker "yet another Module::Start(?:er)?" 
----
Net-Amazon-HadoopEC2-0.02
http://search.cpan.org/~danjou/Net-Amazon-HadoopEC2-0.02/
perl interface to work with Hadoop-EC2 
----
Net-Mosso-CloudFiles-0.32
http://search.cpan.org/~lbrocard/Net-Mosso-CloudFiles-0.32/
Interface to Mosso CloudFiles service 
----
Net-SNMP-Mixin-IpRouteTable-0.01_01
http://search.cpan.org/~gaissmai/Net-SNMP-Mixin-IpRouteTable-0.01_01/
mixin class for the mib-II ipRouteTable 
----
Net-Server-Coro-0.3
http://search.cpan.org/~alexmv/Net-Server-Coro-0.3/
A co-operative multithreaded server using Coro 
----
Net-Server-Coro-0.4
http://search.cpan.org/~alexmv/Net-Server-Coro-0.4/
A co-operative multithreaded server using Coro 
----
POE-Component-CSS-Minifier-0.0101
http://search.cpan.org/~zoffix/POE-Component-CSS-Minifier-0.0101/
non-blocking wrapper around CSS::Minifier with URI fetching abilities 
----
POE-Component-SmokeBox-0.01_10
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.01_10/
POE enabled CPAN smoke testing with added value. 
----
Pod-Elemental-0.001
http://search.cpan.org/~rjbs/Pod-Elemental-0.001/
work with nestable POD elements 
----
Pod-Eventual-0.004
http://search.cpan.org/~rjbs/Pod-Eventual-0.004/
read a POD document as a series of trivial events 
----
Pod-Weaver-2.000
http://search.cpan.org/~rjbs/Pod-Weaver-2.000/
do horrible things to POD, producing better docs 
----
Rose-DB-0.747
http://search.cpan.org/~jsiracusa/Rose-DB-0.747/
A DBI wrapper and abstraction layer. 
----
Rose-HTML-Objects-0.555
http://search.cpan.org/~jsiracusa/Rose-HTML-Objects-0.555/
Object-oriented interfaces for HTML. 
----
SVK-v2.2.1
http://search.cpan.org/~clkao/SVK-v2.2.1/
A Distributed Version Control System 
----
Template-Plugin-ForumCode-0.0.3
http://search.cpan.org/~chisel/Template-Plugin-ForumCode-0.0.3/
class for "ForumCode" filter 
----
Test-Formats-0.12
http://search.cpan.org/~rjray/Test-Formats-0.12/
An umbrella class for test classes that target formatted data 
----
Test-Output-0.11
http://search.cpan.org/~ssoriche/Test-Output-0.11/
Utilities to test STDOUT and STDERR messages. 
----
Text-CSV-1.10
http://search.cpan.org/~makamaka/Text-CSV-1.10/
comma-separated values manipulator (using XS or PurePerl) 
----
Text-CSV-Encoded-0.07
http://search.cpan.org/~makamaka/Text-CSV-Encoded-0.07/
Encoding aware Text::CSV. 
----
WWW-Ebay-0.086
http://search.cpan.org/~mthurn/WWW-Ebay-0.086/
Search and manage eBay auctions 
----
WWW-Search-Ebay-2.248
http://search.cpan.org/~mthurn/WWW-Search-Ebay-2.248/
backend for searching www.ebay.com 
----
WWW-VieDeMerde-0.011
http://search.cpan.org/~iderrick/WWW-VieDeMerde-0.011/
A perl module to use the viedemerde.fr API 
----
WebService-MusicBrainz-0.19
http://search.cpan.org/~bfaist/WebService-MusicBrainz-0.19/
----
XML-DT-0.52
http://search.cpan.org/~ambs/XML-DT-0.52/
a package for down translation of XML files 
----
XML-Feed-0.22
http://search.cpan.org/~simonw/XML-Feed-0.22/
Syndication feed parser and auto-discovery 
----
indirect-0.08
http://search.cpan.org/~vpit/indirect-0.08/
Lexically warn about using the indirect object syntax. 
----
maybe-0.01
http://search.cpan.org/~dexter/maybe-0.01/
use a Perl module and ignore error if can't be loaded 
----
namespace-clean-0.09
http://search.cpan.org/~flora/namespace-clean-0.09/
Keep imports and functions out of your namespace 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Wed, 22 Oct 2008 22:00:54 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: Where is the documentation to show how to add a PNG file to a PDF
Message-Id: <c5185993-b852-4b0b-989d-e7dbd1e080a8@t42g2000hsg.googlegroups.com>

On Oct 23, 12:32=A0am, Christian Winter <thepoet_nos...@arcor.de> wrote:
> Ted Byers wrote:
> > I successfully created a number of PNG files using chart, and I
> > successfully created my PDF file. =A0Both look quite nice.
>
> > I did find, in the documentation of PDF::API2 the image functions
> > (e.g. my $png1 =3D $pdf->image_png("chart1.png");), but these do not
> > actually add the image to the current page. =A0I have looked through al=
l
> > the documentation I have for PDFs, including PDF::API2, but I do not
> > see anything about how to actually add the png file (which I assume is
> > read by "image_png") to a specific page.
>
> > I did find the following for PDF::Report
>
> > "$pdf->addImg($file, $x, $y);
> > "Add image $file to the current page at position ($x, $y).
>
> > "$pdf->addImgScaled($file, $x, $y, $scale);
> > "Add image $file to the current page at position ($x, $y) scaled to
> > $scale. "
>
> > But I didn't use PDF::Report, yet, so I am concerned that shifting to
> > it will break the code I have already written. =A0I use PDF::Table for
> > much of my PDF file. =A0Do you know if it plays nicely with
> > PDF::Report? =A0I see PDF::Report is described as a wrapper for
> > PDF::API2, so I would have thought that there would be something like
> > 'addImg' in the PDF::API2 API, but I don't see it there.
>
> > I am looking fo rthe path of least resistance to get these images
> > added to specific pages in my PDF.
>
> You'll have to look into the docs for PDF::API2::Content for the
> image methods (a lot of important information is strewn all over
> the different modules that come with PDF::API2). Basically, the image
> is added to the graphics canvas, which you have to retrieve first.
>
> my $img =3D $pdf->image_png("chart1.png");
> my $gfx =3D $page->gfx;
> $gfx->image( $img, $posx, $posy );
>
> HTH
> -Chris- Hide quoted text -
>
> - Show quoted text -

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.

Thanks again

Ted


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

Date: Thu, 23 Oct 2008 06:32:10 +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: <48fffe34$0$14068$9b4e6d93@newsspool3.arcor-online.net>

Ted Byers wrote:
> I successfully created a number of PNG files using chart, and I
> successfully created my PDF file.  Both look quite nice.
> 
> I did find, in the documentation of PDF::API2 the image functions
> (e.g. my $png1 = $pdf->image_png("chart1.png");), but these do not
> actually add the image to the current page.  I have looked through all
> the documentation I have for PDFs, including PDF::API2, but I do not
> see anything about how to actually add the png file (which I assume is
> read by "image_png") to a specific page.
> 
> I did find the following for PDF::Report
> 
> "$pdf->addImg($file, $x, $y);
> "Add image $file to the current page at position ($x, $y).
> 
> "$pdf->addImgScaled($file, $x, $y, $scale);
> "Add image $file to the current page at position ($x, $y) scaled to
> $scale. "
> 
> But I didn't use PDF::Report, yet, so I am concerned that shifting to
> it will break the code I have already written.  I use PDF::Table for
> much of my PDF file.  Do you know if it plays nicely with
> PDF::Report?  I see PDF::Report is described as a wrapper for
> PDF::API2, so I would have thought that there would be something like
> 'addImg' in the PDF::API2 API, but I don't see it there.
> 
> I am looking fo rthe path of least resistance to get these images
> added to specific pages in my PDF.

You'll have to look into the docs for PDF::API2::Content for the
image methods (a lot of important information is strewn all over
the different modules that come with PDF::API2). Basically, the image
is added to the graphics canvas, which you have to retrieve first.

my $img = $pdf->image_png("chart1.png");
my $gfx = $page->gfx;
$gfx->image( $img, $posx, $posy );

HTH
-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 1941
***************************************


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