[21993] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4215 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 4 14:10:58 2002

Date: Wed, 4 Dec 2002 11:05:13 -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           Wed, 4 Dec 2002     Volume: 10 Number: 4215

Today's topics:
    Re: advanced html form question <wsegrave@mindspring.com>
    Re: child signal ctcgag@hotmail.com
    Re: child signal <spamhater@keepyourfilthyspamtoyourself.co.uk>
    Re: Closing an unsaved modded Excel spreadsheet? (remove the obvious)
        Converting DMYHMS to epoch <k_devlin@hotmail.com>
    Re: Converting DMYHMS to epoch <k_devlin@hotmail.com>
    Re: Converting DMYHMS to epoch <ubl@schaffhausen.de>
    Re: Converting DMYHMS to epoch <dave@dave.org.uk>
        Getting a URL Page (Kasp)
        help with Can't modify constant item in scalar assignme <mothra@nowhereatall.com>
    Re: help with Can't modify constant item in scalar assi <mothra@nowhereatall.com>
    Re: help with Can't modify constant item in scalar assi <jeff@vpservices.com>
    Re: help with Can't modify constant item in scalar assi <uri@stemsystems.com>
    Re: how to get it quoted? <du_bing@hotmail.com>
    Re: how to get it quoted? (Walter Roberson)
        Interprocess Communication <hal@thresholddigital.com>
    Re: Interprocess Communication news@roaima.freeserve.co.uk
        Newbie: Translation from PHP to Perl <anthony.heuveline@wanadoo.fr>
    Re: Newbie: Translation from PHP to Perl <wsegrave@mindspring.com>
    Re: Newbie: Translation from PHP to Perl <flavell@mail.cern.ch>
    Re: Newbie: Translation from PHP to Perl <tassilo.parseval@post.rwth-aachen.de>
        NT Drive mappings in perl (Chris Howard)
        Peer certificate not valid <support@nospam-soccerassociation.com>
        Perl Question <kdoherty@atmel.com>
    Re: Perl Question <nobull@mail.com>
        Quick syntax question... <spikey-wan@bigfoot.com>
    Re: Quick syntax question... <tassilo.parseval@post.rwth-aachen.de>
    Re: Quick syntax question... <nobull@mail.com>
    Re: Quick syntax question... <tassilo.parseval@post.rwth-aachen.de>
    Re: Quick syntax question... <spikey-wan@bigfoot.com>
    Re: rolling my own perl-based content management system news@roaima.freeserve.co.uk
    Re: sys/wait.ph problem <dturley@_NOSPAM_pobox.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 4 Dec 2002 12:03:14 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: advanced html form question
Message-Id: <aslgcp$jb5$2@slb5.atl.mindspring.net>

"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:asismp$ha0$2@slb4.atl.mindspring.net...
> "Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
<snip>
> > I suggest that you guys call a truce ;-)
>
> O.K. Truce. Where was the battle? ;-)

Oops! I see where it is now.

"Fred" <joleebaby@hotmail.com>, the OP with the php/mySQL question, wandered
into the "clpmisc" home while looking for "comp.lang.php" home. He didn't
like the free advice he received at the "clpmisc" home, so he shot up one of
its dependencies, "clpmodules".

PP = Pity + Plonk!

Bill Segraves






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

Date: 04 Dec 2002 16:02:30 GMT
From: ctcgag@hotmail.com
Subject: Re: child signal
Message-Id: <20021204110230.165$Sn@newsreader.com>

"Lois" <lois@hotmail.com> wrote:
> Hi all,
>
> I have fork() some children to do some processings and I want to quit the
> whole program when the first child finishes.

> what's the correct way to do this?

Here is a way to do it:

$SIG{CHLD} = \&zombie;
sub zombie
{
     kill -15, $$;
}

By sending the negative signal, it gets sent to the whole "process
group".  As far as I can tell, a "process group" consists of a process and
all of it's decendents.  So here, the parent process kills itself and all
of it's children.

But don't blame me if it crashes your computer and reboots the universe
instead.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Wed, 04 Dec 2002 16:57:11 GMT
From: Alan Wrigley <spamhater@keepyourfilthyspamtoyourself.co.uk>
Subject: Re: child signal
Message-Id: <9cb0a59f4b.spamhater@keepyourfilthyspamtoyourself.co.uk>

In message <20021204110230.165$Sn@newsreader.com>
          ctcgag@hotmail.com wrote:

> "Lois" <lois@hotmail.com> wrote:
> > Hi all,
> >
> > I have fork() some children to do some processings and I want to quit the
> > whole program when the first child finishes.
> 
> > what's the correct way to do this?
> 
> Here is a way to do it:
> 
> $SIG{CHLD} = \&zombie;
> sub zombie
> {
>      kill -15, $$;
> }

A related question:

I want to fork a number of children but I want to ensure that no more
than 10 processes operate at once. I've tried incrementing a counter
when forking the child and then using the zombie() routine to decrement
it, but it appears that if two children finish at the same time the
routine is only called once.

Is there a way to ensure a guaranteed signal for every child?

Alan

-- 
RISC OS - you know it makes cents


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

Date: Wed, 04 Dec 2002 17:51:40 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: Closing an unsaved modded Excel spreadsheet?
Message-Id: <MgrH9.43026$hK4.3812507@bgtnsc05-news.ops.worldnet.att.net>


"Richard S Beckett" <spikey-wan@bigfoot.com> wrote in message
news:asids5$jnk$1@newshost.mot.com...
|
| "Michele Ouellet" <ouellmi@videotron.ca> wrote in message
| news:oO0H9.24106$QT3.279959@weber.videotron.net...
|
| > Actually, the best source of information for this kind of problem
is the
| > "Programming Information" chapter in the Help system for Excel; in
| > particular, the API documentation for Open() and Close(). I think
the
| > hardest part of using OLE is the object model and that is not
really a
| Perl
| > question. ( I have had similar problems with Word... )
| >
| > Good Luck,
| >
| > Michele Ouellet.
|
| Thanks Michelle.
|
| I have now read the Excel documantation...
|
| It says that to close without saving, do this:
|
| ThisWorkbookSaved = True
| ThisWorkbookClose
|
| I have translated this into my script as:
|
| $excel -> {ThisWorkbookSaved} = "True";
| $excel -> {ThisWorkbookClose};
| and
| $book -> Saved = "True";
| $book -> Close;
|
| But (yes you guessed it!) it STILL doesn't work!
|
| Did I do that right? Please save me from premature baldness.
|
| Thanks.
|
| R.
|
I just read the same documentation.  ThisWorkbook returns the workbook
that the script is running in.  You probably want to use the
ActiveWorkbook.  To set the saved property you probably need to do
something like:
$whatever_you_named_the_workbook -> {Saved} = "True";
(Setting a property requires the curlies).

--Rick




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

Date: Wed, 4 Dec 2002 14:42:16 -0000
From: "Kevin" <k_devlin@hotmail.com>
Subject: Converting DMYHMS to epoch
Message-Id: <asl4l7$opu$1@pheidippides.axion.bt.co.uk>

Sorry for probably being clueless but have just started coding in perl and
am trying to convert
a date such as "03-DEC-02" to epoch seconds.

can someone help me with this (initially seemingly) fiddly prob.

Kev




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

Date: Wed, 4 Dec 2002 14:55:27 -0000
From: "Kevin" <k_devlin@hotmail.com>
Subject: Re: Converting DMYHMS to epoch
Message-Id: <asl5du$per$1@pheidippides.axion.bt.co.uk>

sorry, just like to add that im not concerned with hours, mins seconds -
just from that particular date...


"Kevin" <k_devlin@hotmail.com> wrote in message
news:asl4l7$opu$1@pheidippides.axion.bt.co.uk...
> Sorry for probably being clueless but have just started coding in perl and
> am trying to convert
> a date such as "03-DEC-02" to epoch seconds.
>
> can someone help me with this (initially seemingly) fiddly prob.
>
> Kev
>
>




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

Date: Wed, 04 Dec 2002 16:05:18 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Converting DMYHMS to epoch
Message-Id: <asl8so$a7n$1@news.dtag.de>

Kevin wrote:

> 
> "Kevin" <k_devlin@hotmail.com> wrote in message
> news:asl4l7$opu$1@pheidippides.axion.bt.co.uk...
> 
>>Sorry for probably being clueless but have just started coding in perl and
>>am trying to convert
>>a date such as "03-DEC-02" to epoch seconds.
>>
>>can someone help me with this (initially seemingly) fiddly prob.

 > sorry, just like to add that im not concerned with hours, mins seconds -
 > just from that particular date...


Time::Local
http://search.cpan.org/author/JHI/perl-5.8.0/lib/Time/Local.pm

Should Do what you want.

Greetings,
->malte



-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: Wed, 04 Dec 2002 16:44:21 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Converting DMYHMS to epoch
Message-Id: <pan.2002.12.04.16.44.20.923410@dave.org.uk>

On Wed, 04 Dec 2002 14:42:16 +0000, Kevin wrote:

> Sorry for probably being clueless but have just started coding in perl and
> am trying to convert
> a date such as "03-DEC-02" to epoch seconds.
> 
> can someone help me with this (initially seemingly) fiddly prob.

One way would be to strip the date apart, convert "DEC" to a number and
then use the "timelocal" function from Time::Local (part of the standard
distribution).

IMO, an easier way would be to use the "strptime" function from
Time::Piece (not part of the standard distribution - get it from CPAN).

hth,

Dave...

-- 
  "Don't you boys know any _nice_ songs?"



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

Date: 4 Dec 2002 10:57:00 -0800
From: kasp@epatra.com (Kasp)
Subject: Getting a URL Page
Message-Id: <3b04990d.0212041057.5abbb2c1@posting.google.com>

Hi!,

I am a newbie in Perl World and my task is to get a Web Page, given
the URL, and store it's contents in a temp.txt file.
Frankly, I have to do more than that...but as of now getting a web
page is bugging me.

I want to know how I can do this. Is there a module to do this? (I bet
there is..but dont know).

A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
Thanks


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

Date: Wed, 4 Dec 2002 10:33:31 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: help with Can't modify constant item in scalar assignment but it does not tell me why?
Message-Id: <3dee4a54$1@usenet.ugs.com>

Hi All,
I am in the process of writing a Perl script that will run under mod_perl.
the script uses the text template system for generating the HTML and I
am receiving an error ( in the apache log file) that I cannot fix. So I
added the use diagnostics to the program and ran from teh command line
this was the result:
-----------------result----------------
/app/perl5.8.0/bin/perl -c new_uga.pl
Can't modify constant item in scalar assignment at new_uga.pl line 314, near
"%params,"
new_uga.pl had compilation errors (#1)
    (F) You aren't allowed to assign to the item indicated, or otherwise try
    to change it, such as with an auto-increment.

Uncaught exception from user code:
        Can't modify constant item in scalar assignment at new_uga.pl line
314, near "%params,"
new_uga.pl had compilation errors.
------------end result----------------

line 314 is part of a sub

sub reassemble_uga_file   {

my %params = $query->Vars;
my $file_template = 'draft.tpl';
my $file_string = '';

my $template = Template->new({
               INCLUDE_PATH =>$config_dirs->value("template"),});

my $vars = {
   data =\%params,# this is line 314 in my script that the error is refering
to
   };


 $template->process($file_template, $vars,\$file_string)
  || die "Template process failed: ", $template->error(), "\n";

return $file_string;

My questions is why am I not allowed to assign the item indicated? The error
does not tell me why. All I am trying to do is take the params from the form
and  generate a string based on a template (kinda like using a format)
I don't want to modify anything.




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

Date: Wed, 4 Dec 2002 10:46:07 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: help with Can't modify constant item in scalar assignment but it does not tell me why?
Message-Id: <3dee4d48$1@usenet.ugs.com>


"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7adjlvdfz.fsf@mail.sysarch.com...
>
>   M>                INCLUDE_PATH =>$config_dirs->value("template"),});
>                                  ^^
>   M> my $vars = {
>   M>    data =\%params,# this is line 314 in my script that the error is
refering
>              ^^
>
> one of those is not like the other.
>
> uri
>
> --
> Uri Guttman  ------  uri@stemsystems.com  --------
http://www.stemsystems.com
I feel so stupid !!

Thanks Uri :-)

Mothra




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

Date: Wed, 04 Dec 2002 10:42:59 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: help with Can't modify constant item in scalar assignment but it does not tell me why?
Message-Id: <3DEE4CB3.3040202@vpservices.com>

Mothra wrote:


>         Can't modify constant item in scalar assignment at new_uga.pl line

 ...

> my $vars = {
>    data =\%params


The problem is greater than you can handle.

As in, a missing greater than character ... hash keys are assigned with 
{key => value}, not {key = value}.

-- 
Jeff





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

Date: Wed, 04 Dec 2002 18:36:34 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: help with Can't modify constant item in scalar assignment but it does not tell me why?
Message-Id: <x7adjlvdfz.fsf@mail.sysarch.com>

>>>>> "M" == Mothra  <mothra@nowhereatall.com> writes:

  M>                INCLUDE_PATH =>$config_dirs->value("template"),});
                                 ^^

  M> my $vars = {
  M>    data =\%params,# this is line 314 in my script that the error is refering
             ^^

one of those is not like the other. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 04 Dec 2002 10:24:19 -0600
From: user <du_bing@hotmail.com>
Subject: Re: how to get it quoted?
Message-Id: <3DEE2C32.8759361B@hotmail.com>

Ah, no error this time.  But '\"c24b18d4bb4afdf052330678af9a601d+sent mail\"\@neo.tamu.edu' was
treated like 'c24b18d4bb4afdf052330678af9a601d+sent, mail@neo.tamu.edu' (note a comma was
inserted).  Indeed, it's not a perl problem.  Although RFC822 suggests get localpart including space
double quoted, seems not every mail program (e.g. mailx) can handle it.  I've tried various
combinations of single and double quotes. Neither works.

I know some Perl module (e.g. append() of IMAPClient) can accomplish what I want, but if directly
delivering to the folder works (simplest way, maybe), I'd not like to use modules.

Thanks for all the help,

Bing

Walter Roberson wrote:

> In article <3DED2BAA.31559954@hotmail.com>, user  <du_bing@hotmail.com> wrote:
> :Thanks for the response, Walter.  I tried your suggestion (open(MAIL,"|mailx -s 'for test'
> :'"c24b18d4bb4afdf052330678af9a601d+sent mail"\@neo.tamu.edu'")).  Instead of 'User unknown', it
> :returned the following errors:
>
> :Bareword found where operator expected at ./z.pl line 5, near ""|mailx -s 'for t
>
> Opps, you'll have to escape the internal double-quotes:
>
> open(MAIL,"|mailx -s 'for test' '\"c24b18d4bb4afdf052330678af9a601d+sent mail\"\@neo.tamu.edu'")
> --
> millihamlet: the average coherency of prose created by a single monkey
> typing randomly on a keyboard. Usenet postings may be rated in mHl.
>    -- Walter Roberson



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

Date: 4 Dec 2002 17:27:56 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: how to get it quoted?
Message-Id: <asldus$k8j$1@canopus.cc.umanitoba.ca>

In article <3DEE2C32.8759361B@hotmail.com>, user  <du_bing@hotmail.com> wrote:
:Ah, no error this time.  But '\"c24b18d4bb4afdf052330678af9a601d+sent mail\"\@neo.tamu.edu' was
:treated like 'c24b18d4bb4afdf052330678af9a601d+sent, mail@neo.tamu.edu' (note a comma was
:inserted).  Indeed, it's not a perl problem.  Although RFC822 suggests get localpart including space
:double quoted, seems not every mail program (e.g. mailx) can handle it.

Worse news for your purposes: the mail exchanger for neo.tamu.edu
is stripping off double quotes. If I telnet to the smtp port of
smtp-relay.tamu.edu and construct raw mail messages (no MTA involved
at all) then messages
RCPT TO:<"c24b18d4bb4afdf052330678af9a601d+sent mail"@neo.tamu.edu>
do get forwarded, but when local delivery is attempted, it is 
delivery to  <c24b18d4bb4afdf052330678af9a601d+sent mail>
and the destination mailer then complains about errors in the parameters.

When using raw mail messages, I did not get a bounce if I used

RCPT TO:<""c24b18d4bb4afdf052330678af9a601d+sent mail""@neo.tamu.edu>
or
RCPT TO:<"\"c24b18d4bb4afdf052330678af9a601d+sent mail\""@neo.tamu.edu>

but my MUA, BSD Mail, has trouble dealing with the \" . It's
hard to get all the levels happy simultaneously when some of the
layers are misbehaving.

--
   I don't know if there's destiny,
   but there's a decision!                  -- Wim Wenders (WoD)


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

Date: Wed, 04 Dec 2002 15:02:26 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Interprocess Communication
Message-Id: <6OoH9.230811$QZ.36198@sccrnsc02>

What is the easiest way I can get the CGI programs running on mod_perl as 
the user apache to signal another program running under another user?  (I 
tried sending signals, but I can't send signals from a program running 
under one user to a program running under another user.)

Details of the situation are:

I'm not a professional programmer and I've never had to do anything with 
interprocess communication before.  I'm working on a project for a friend.  
I have a system on his office LAN and he can control it through a web page 
(I'm using mod_perl on Apache).  He needs to be able to change some 
settings, which I've had no problem setting up.  The problem is that there 
are times when he has to be able to change a setting from the web page and 
the program has to respond immediately.

I don't want to give the user apache any extra access, since I am not sure 
of the security of his LAN.  I have the web server running as apache and 
the other programs that are running are either running as root 
(unfortunately necesssary), or as another user.

Right now I'm doing this by creating a specific setting file that contains 
only "on" or "off".  I have the CGI Perl program changing this file to "on" 
when the other program needs to respond immediately.  The other program 
that is running has a daemon (in Perl) that checks this file every second 
to see if it's changed.  This takes up a LOT of CPU time and I've noticed 
that at times it seems to make the hard drive run for a few hours straight 
-- it doesn't seem to always get buffered like it should (I'm running this 
on Mandrake Linux 8.2).

I've found I can't have the CGI program just send a signal (like USR1 or 
USR2) to the other program, since they aren't both run by the same user.  
I've tried using internet socekets, as described in the "Blue Camel," but I 
can't get them to work (it may be that the system has ports not used by 
specific programs blocked).

I've read through the section on IPC in the Blue Camel, but, not being a 
professional programmer, I think I'm missing quite a bit.


Hal


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

Date: Wed, 4 Dec 2002 17:50:44 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: Interprocess Communication
Message-Id: <k9flsa.0p1.ln@moldev.cmagroup.co.uk>

Hal Vaughan <hal@thresholddigital.com> wrote:
> What is the easiest way I can get the CGI programs running on mod_perl as 
> the user apache to signal another program running under another user?  (I 
> tried sending signals, but I can't send signals from a program running 
> under one user to a program running under another user.)

I don't see this is a perl specific issue; instead it's to do with OS
permissions. Therefore, at the risk of being totally off-topic I'm going
to suggest an OS centric solution instead.

Further, I shall assume you're using UNIX.

The only two ways [*] a process can send an OS level signal to a process
owned by another user is either as root or when it's masquerading as
the destination userid.

The second takes the rule of least privilege, so I'll give you some
pointers there. Please note that this is NOT a totally secure solution -
the best approach is a custom "kill" command that looks in a dedicated
place for the PID, verifies it's the right one, and sends one of a set
of predetermined signals to the known process. I'll give you specific
implementation details offline if you email me (chris-usenet@..., please)

Take the "kill" command (often /bin/kill) and copy it to a local directory that can be accessed by your web application. Change its ownership to that of the destination process you want to signal, and its group to that of the web process. As root, set the setuid bit on the executable and remove all access for anyone other than the owner and the group. Use that program as a "kill" replacement.

    $ cp /bin/kill /some/securedir		# NOT in your web tree
    $ su
    # chown destuser /some/securedir/kill	# NOT root
    # chgrp webgroup /some/securedir/kill
    # chmod u+s,g=rx,o= /some/securedir/kill

Chris

[*] these are the two ways that I can think of, right now
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Wed, 4 Dec 2002 16:30:33 +0100
From: "Anthony" <anthony.heuveline@wanadoo.fr>
Subject: Newbie: Translation from PHP to Perl
Message-Id: <asl71e$1c$1@news-reader12.wanadoo.fr>

Hi,

    For those who master both PHP and Perl, I have a problem converting an
instruction. Here is the problem:

    <?
    header("Content-type: application/force-download");
    header("Content-Disposition: attachment; filename=downloaded.pdf");
    readfile("downloaded.pdf");
    ?>

    As this program works and I didn't find one example in Perl dealing with
this function (download forcing), I tried to convert like this but it
doesn't work at all:

    print "Content-type: application/force-download\n";
    print "Content-Disposition: attachment; filename=downloaded.pdf\n\n"

    open(PDF, "downloaded.pdf") || die "Can't open file";

    while(defined($a=<PDF>)) {
         print $a;
    }

    close(PDF);

    Obviously, the problem comes from the translation of readfile in the PHP
code. Does anyone know what is equivalent?

    Thank you in advance,

Anthony




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

Date: Wed, 4 Dec 2002 11:09:33 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Newbie: Translation from PHP to Perl
Message-Id: <asld0g$odm$2@slb0.atl.mindspring.net>

"Anthony" <anthony.heuveline@wanadoo.fr> wrote in message
news:asl71e$1c$1@news-reader12.wanadoo.fr...
<snip>

I assume you have

#!perl -w
use strict;

or whatever is appropriate for the system you're using (to run your script),
at the top of your script.

>     print "Content-type: application/force-download\n";
>     print "Content-Disposition: attachment; filename=downloaded.pdf\n\n"

You left a semi-colon off of the end of the above line. Didn't you do

perl -c program.pl

from the command line to see the diagnostics perl gives you?


>
>     open(PDF, "downloaded.pdf") || die "Can't open file";
>
>     while(defined($a=<PDF>)) {
>          print $a;
>     }

IMO, this is a dangerous way to read a PDF file. What assurance do you have
that reading a binary file a line at a time will get all of the content of
the file?

>
>     close(PDF);
>

You should check to see if you really closed the file, issuing the
appropriate message if you didn't.

>     Obviously, the problem comes from the translation of readfile in the
PHP
> code. Does anyone know what is equivalent?
>

Sorry, I don't translate PHP.

OTOH, you might examine what is your real problem. Is the task really
translating a PHP script to a Perl script?

If the *real* task is to download a PDF file, Perl provides more than one
way for you to do it. See page 207 of _Learning Perl_, 2nd edition for a
one-liner you could use to download a file.

Cheers.

Bill Segraves




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

Date: Wed, 4 Dec 2002 18:54:18 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Newbie: Translation from PHP to Perl
Message-Id: <Pine.LNX.4.40.0212041822140.22227-100000@lxplus074.cern.ch>

On Dec 4, William Alexander Segraves inscribed on the eternal scroll:

> >     print "Content-type: application/force-download\n";
> >     print "Content-Disposition: attachment; filename=downloaded.pdf\n\n"

[good points omitted]

> >     while(defined($a=<PDF>)) {

> IMO, this is a dangerous way to read a PDF file.

It's surely not optimal...

> Sorry, I don't translate PHP.

OK, but I think it's clear enough what the chap wants to achieve.
(I'd counsel against it, citing the other approaches mentioned in
http://www.htmlhelp.com/faq/html/media.html#force-download , but I'm
well aware that web authors regularly think they know better what
their users want...)

> If the *real* task is to download a PDF file, Perl provides more than one
> way for you to do it.

But you're evidently offering a technique (with LWP) to be applied by
the client; whereas I'm sure the questioner wanted something they
could impose on the client from the server side.

The Perl part of the question would seem to be addressed here

http://www.perldoc.com/perl5.8.0/pod/perlopentut.html#Binary-Files

showing a file being copied in buffer-sized chunks.  Remember to
binmode() both the input and the output (this is the proper thing to
do even on platforms where it makes no difference, despite the
murmurings from the Unix bigots which still appear in the
documentation, despite Perl's commendable aim to be a portable
language).  (Don't get me wrong - I do my serious programming on unix
too, but I try not to be a bigot about it, having programmed IBM
mainframes, VAXes, and previously PDP8 and earlier things - see the
machine in
http://www.scit.wlv.ac.uk/university/scit/history/witch.gif for
starters ;-).

But getting back to the plot, I would commend to the original poster a
perusal of the group's regular "Posting Guidelines" for several things
they should do - and evidently omitted to do - before asking for
Perl-specific advice here.

good luck



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

Date: 4 Dec 2002 18:27:33 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Newbie: Translation from PHP to Perl
Message-Id: <aslhel$d4$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Alan J. Flavell:

> language).  (Don't get me wrong - I do my serious programming on unix
> too, but I try not to be a bigot about it, having programmed IBM
> mainframes, VAXes, and previously PDP8 and earlier things - see the
> machine in
> http://www.scit.wlv.ac.uk/university/scit/history/witch.gif for
> starters ;-).

The guy on the right, is that John von Neumann? Or wasn't he yet born by
the time this picture was taken? ;-)

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: 4 Dec 2002 10:08:04 -0800
From: google@chris-howard.fsnet.co.uk (Chris Howard)
Subject: NT Drive mappings in perl
Message-Id: <4287fb4c.0212041008.486961fc@posting.google.com>

Hi,

I have a perl script which, does a :-

system("net use R:  \\\\$target_host\\$sharename")

which maps the R: drive fine, however, when the script has finished, I
find it impossible to unmap the drive.

If I run "net use R: /d",  I get "The network connection could not be
found."

In explorer it shows as "Remote Disk" rather than "Network
Connection".

I've run subst, which I know can map remote drives - no entries.

Has anyone got any ideas ??

Thanks

Chris.


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

Date: Wed, 4 Dec 2002 14:27:29 +0000
From: Customer support <support@nospam-soccerassociation.com>
Subject: Peer certificate not valid
Message-Id: <KHoGjHCRDh79Ewk8@soccerassociation.org.uk>

I'm using a Robot (with Crypt::SSLeay) to post data to a number of
secure pages, however the final page gives the following:

Client-SSL-Warning: Peer certificate not verified

If I post the same data from a browser it works fine.

Has anyone got any ideas?

Thanks,
-- 
Customer support
   [web] http://www.soccerassociation.com
[e-mail] support@soccerassociation.com
   [fax] +44 (0) 115 941 1634



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

Date: Wed, 04 Dec 2002 19:13:03 +0000
From: Kevin Doherty <kdoherty@atmel.com>
Subject: Perl Question
Message-Id: <3DEE53BF.87E1FFA2@atmel.com>

Hi All,
        Simple question.... but beyond me!?  I am looking for a bit of
help in
finishing a small program. The small program is to parse in a text file
and add a few lines and delete a few lines. The problem I have is to
delete a few lines. Can't get it to work properly!! An example of the
lines to
be deleted are 

DEFINE PINS
<PIN INFO>
<PIN INFO>
<PIN INFO>
END PINS

Thanks
Kevin


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

Date: 04 Dec 2002 18:04:03 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl Question
Message-Id: <u9wumpvey4.fsf@wcl-l.bham.ac.uk>

Kevin Doherty <kdoherty@atmel.com> writes:

> Subject: Re: Perl Question

Please put the subject of your post in the Subject of your post.  If
in doubt try this simple test.  Imagine you could have been bothered
to have done a search before you posted.  Next imagine you found a
thread with your subject line.  Would you have been able to recognise
it as the same subject?

> Hi All,
>         Simple question.... but beyond me!?  I am looking for a bit of
> help in
> finishing a small program. The small program is to parse in a text file
> and add a few lines and delete a few lines. The problem I have is to
> delete a few lines.

See FAQ: "How do I change one line in a file/delete a line in a
       file/insert a line in the middle of a file/append to the
       beginning of a file?"

> Can't get it to work properly!!

I can't get my crystal ball to work properly.  

This isn't a psychic helpline.  I guess you'll have to post your small
program here if you want us to see it.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 4 Dec 2002 15:28:18 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Quick syntax question...
Message-Id: <asl6vt$9dc$1@newshost.mot.com>

Chaps,

I'm reading the Net::Ping documentation, and it says :

Net::Ping->new([$proto [, $def_timeout [, $bytes]]]);

I'm happy for the protocol ($proto) and timeout ($def_timeout) to be their
default values, but I do want to specify the number of bytes.

I don't understand how to do this, without having to specify the first 2
variables, would someone mind elucidating me, please?

Thanks.

R.





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

Date: 4 Dec 2002 17:53:57 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Quick syntax question...
Message-Id: <aslffl$rdj$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Richard S Beckett:

> I'm reading the Net::Ping documentation, and it says :
> 
> Net::Ping->new([$proto [, $def_timeout [, $bytes]]]);
> 
> I'm happy for the protocol ($proto) and timeout ($def_timeout) to be their
> default values, but I do want to specify the number of bytes.
> 
> I don't understand how to do this, without having to specify the first 2
> variables, would someone mind elucidating me, please?

Net::Ping->new() checks whether $proto and $def_timeout have true
values, otherwise they are set to their defaults. To use the defaults it
would therefore be enough to set those two to 0 and add your custom
third parameter:

    my $ping = Net::Ping->new(0, 0, 64);

This can't be generalized however: Other functions could check for
definedness in which case the first two parameters would need to be set
to undef. A third way could even be checking the length of @_.

Whatever it is, if you want to set $bytes, you must set the first two
parameters as well. Having a look at Net::Ping's source might be helpful
here. It suggests doing the following:

    my $ping = Net::Ping->new( $Net::Ping::def_proto,
                               $Net::Ping::def_timeout,
                               $your_custom_bytes );

Net::Ping has its defaults as package variables so you can access them
from your programs by fully qualifying them.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: 04 Dec 2002 17:55:50 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Quick syntax question...
Message-Id: <u94r9twtw9.fsf@wcl-l.bham.ac.uk>

"Richard S Beckett" <spikey-wan@bigfoot.com> writes:

> Subject: Re: Quick syntax question...

Please put the subject of your post in the Subject of your post.  If
in doubt try this simple test.  Imagine you could have been bothered
to have done a search before you posted.  Next imagine you found a
thread with your subject line.  Would you have been able to recognise
it as the same subject?

Could you really not have come up with something like:

Subject: Specify (n)th argument to method without 1st .. (n-1)th

> I'm reading the Net::Ping documentation, and it says :
> 
> Net::Ping->new([$proto [, $def_timeout [, $bytes]]]);
> 
> I'm happy for the protocol ($proto) and timeout ($def_timeout) to be their
> default values, but I do want to specify the number of bytes.
> 
> I don't understand how to do this, without having to specify the first 2
> variables, would someone mind elucidating me, please?

It is impossible, however, most Perl programmers would write their
libraries so as to allow you to use undef in this situtation.

I've not tested to see if the author of Net::Ping follows this
convention.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 4 Dec 2002 18:14:42 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Quick syntax question...
Message-Id: <aslgmi$sot$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Brian McCauley:

> "Richard S Beckett" <spikey-wan@bigfoot.com> writes:

>> I'm reading the Net::Ping documentation, and it says :
>> 
>> Net::Ping->new([$proto [, $def_timeout [, $bytes]]]);
>> 
>> I'm happy for the protocol ($proto) and timeout ($def_timeout) to be their
>> default values, but I do want to specify the number of bytes.
>> 
>> I don't understand how to do this, without having to specify the first 2
>> variables, would someone mind elucidating me, please?
> 
> It is impossible, however, most Perl programmers would write their
> libraries so as to allow you to use undef in this situtation.
> 
> I've not tested to see if the author of Net::Ping follows this
> convention.

He does, yet I think the question shows that its author had better used
named parameters which would have allowed for:

    my $p = Net::Ping->new( size => $bytes );
    
Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Wed, 4 Dec 2002 18:10:05 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Quick syntax question...
Message-Id: <aslgf9$bs8$1@newshost.mot.com>

Thanks Tassilo.

R.




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

Date: Wed, 4 Dec 2002 14:12:49 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: rolling my own perl-based content management system
Message-Id: <1h2lsa.q7p.ln@moldev.cmagroup.co.uk>

Nuba <nuba@dcc.ufmg.br> wrote:
>    I've rolled my own perl-based content management system, 
>    using 'template toolkit' and 'mysql'. 

> I know there are many content management systems flowing around, but I
> haven't been able to find a serious, enterprise-oriented, perl based
> one. Of course, these is slashcode, but it seems to be more community
> than content driven.

Is bricolage (http://bricolage.cc) the sort of thing you're looking for?

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Wed, 04 Dec 2002 10:26:11 -0500
From: David Turley <dturley@_NOSPAM_pobox.com>
Subject: Re: sys/wait.ph problem
Message-Id: <pan.2002.12.04.15.26.07.561896.30423@_NOSPAM_pobox.com>

On Tue, 03 Dec 2002 20:57:20 -0500, David Turley wrote:


> but the project's moving. (And they said it would run on Linux! :-)
> 

Obviously, that should have been "wouldn't run on Linux."  :-)


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

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.  

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 V10 Issue 4215
***************************************


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