[18196] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 364 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 27 09:05:33 2001

Date: Tue, 27 Feb 2001 06:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983282712-v10-i364@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Feb 2001     Volume: 10 Number: 364

Today's topics:
        -e and empty file name <peter.lerup@ecs.ericsson.se>
    Re: -e and empty file name (EED)
    Re: -e and empty file name (Rafael Garcia-Suarez)
    Re: -e and empty file name <peter.lerup@ecs.ericsson.se>
    Re: -e and empty file name (Martien Verbruggen)
    Re: Any tips on creating file records from a web form? <iltzu@sci.invalid>
    Re: calculation of a size of the directory (EED)
        Date formatting <s.attwell@snet.net>
    Re: Date formatting (Bernard El-Hagin)
        Etymology of hash <lmoran@wtsg.com>
    Re: form/cgi help really needed! nobull@mail.com
    Re: How do I test whether a CODE reference is an NOP? <Jerome.Abela@free.fr>
    Re: How the CLPM turns nobull@mail.com
    Re: How the CLPM turns (Bernard El-Hagin)
        mod_perl script fail to execute correctly <not@defined.com>
    Re: Off-topic: generating Excel _sheets_ <jonni@ifm.liu.se>
    Re: Off-topic: generating Excel _sheets_ (EED)
    Re: Off-topic: generating Excel _sheets_ (John McNamara)
        OT unwanted exclamation marks <dcs@ntlworld.com>
    Re: OT unwanted exclamation marks (Bernard El-Hagin)
    Re: OT unwanted exclamation marks <dcs@ntlworld.com>
    Re: Perl CGI and Apache under Win98/NT <knightrid@SPAMSUXhotmail.com>
        Perl program review request (Bill Feidt)
    Re: perl/CGI question <xu@redbird.co.uk>
    Re: perl/CGI question <wells@cedarnet.org>
    Re: PROPOSAL: Graphics::ColorNames <bart.lateur@skynet.be>
        sending to sockets <tfiedler@zen.moldsandwich.com>
    Re: Somewhat complicated hash from DB question <h.camp@scm.de>
    Re: timeout connect() with select? nobull@mail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Feb 2001 13:27:14 +0100
From: "Peter Lerup" <peter.lerup@ecs.ericsson.se>
Subject: -e and empty file name
Message-Id: <97g5rj$gn3$1@newstoo.ericsson.se>

Hi

Does anyone know why the file test operator -e return a true value when an
empty file name is used in Perl version 5.6.0? This was not the case in
5.003.

Example:

print -e ""

Thanks
/Peter

Peter Lerup
Ericsson Mobile Communications





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

Date: Tue, 27 Feb 2001 13:58:32 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: -e and empty file name
Message-Id: <3A9BA478.3CC17AF5@eed.ericsson.se>

Peter Lerup wrote:
> Does anyone know why the file test operator -e return a true value when an
> empty file name is used in Perl version 5.6.0? This was not the case in
> 5.003.
> 
> Example:
> 
> print -e ""

It is not:

maas34:  /opt/local/perl-5.6.0/bin/perl -e 'print -e ""'
maas34:  /opt/local/perl-5.005/bin/perl -e 'print -e ""'
maas34:  /opt/local/perl-5.004/bin/perl -e 'print -e ""'
maas34:  /opt/local/perl-5.003/bin/perl -e 'print -e ""'
maas34:


Regards
Alex


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

Date: Tue, 27 Feb 2001 13:01:12 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: -e and empty file name
Message-Id: <slrn99n981.ss7.rgarciasuarez@rafael.kazibao.net>

Peter Lerup wrote in comp.lang.perl.misc:
> 
> Does anyone know why the file test operator -e return a true value when an
> empty file name is used in Perl version 5.6.0? This was not the case in
> 5.003.
> 
> Example:
> 
> print -e ""

Are you sure ?

$ perl -v

This is perl, v5.6.0 built for i686-linux
[...]

$ perl -le 'print((-e "")?1:0)'
0

If this doesn't work for you on your platform, this is probably a bug.
you should report it (with perlbug).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Much programming is best done with techniques that do not fall within a
narrow definition of "object-oriented." -- Bjarne Stroustrup


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

Date: Tue, 27 Feb 2001 14:10:48 +0100
From: "Peter Lerup" <peter.lerup@ecs.ericsson.se>
Subject: Re: -e and empty file name
Message-Id: <97g8d1$lia$1@newstoo.ericsson.se>

> > Does anyone know why the file test operator -e return a true value when
an
> > empty file name is used in Perl version 5.6.0? This was not the case in
> > 5.003.
> >
> > Example:
> >
> > print -e ""
>
> Are you sure ?
>
> $ perl -v
>
> This is perl, v5.6.0 built for i686-linux
> [...]
>
> $ perl -le 'print((-e "")?1:0)'
> 0
>
> If this doesn't work for you on your platform, this is probably a bug.
> you should report it (with perlbug).
>


I'm using the Win32 version

/Peter



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

Date: Wed, 28 Feb 2001 00:21:00 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: -e and empty file name
Message-Id: <slrn99nads.8ue.mgjv@martien.heliotrope.home>

On Tue, 27 Feb 2001 13:27:14 +0100,
	Peter Lerup <peter.lerup@ecs.ericsson.se> wrote:
> Hi
> 
> Does anyone know why the file test operator -e return a true value when an
> empty file name is used in Perl version 5.6.0? This was not the case in
> 5.003.

Are you sure?

> Example:
> 
> print -e ""

That's hardly a good way to test whether something is true, is it?

$ perl -wl
print -e '' ? "yep" : "nope"
__END__
nope
$ perl -wl
print -e '/tmp' ? "yep" : "nope"
__END__
yep
$ perl -v

This is perl, v5.6.0 built for i686-linux

I don't see the problem. What happens when you execute the above code?
What platform are you on? Are you sure you didn't accidentally do
something like:

$ perl -l
my $yesno = print -e "";
print $yesno ? "yep" : "no";
__END__

yep

in the absence of warnings? In other words: Are you maybe accidentally
using the return value of a print statement? -w would have whined about
uninitialised values, but if you're not using -w you wouldn't know that.
If none of this applies, could you maybe submit the exact piece of code
that you use to determine that the return value of '-e ""' is indeed a
true value?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.   | selective about its friends.
NSW, Australia                  | 


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

Date: 27 Feb 2001 12:52:00 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Any tips on creating file records from a web form?
Message-Id: <983277664.7206@itz.pp.sci.fi>

[Jeopardectomy performed.  Please reply below quoted text.]

In article <t9m1fhcnho1417@corp.supernews.com>, Brian wrote:
>"Ilmari Karonen" <iltzu@sci.invalid> wrote in message
>news:983217282.27707@itz.pp.sci.fi...
>>
>> Take a look at the query_string() method.  The returned value should
>> be one line of ASCII text, and you can turn it back into a CGI object
>> by passing it to CGI->new().
>>
>> Depending on your needs, the save() method can also be useful.
>
>I know how to get the info from the form.  I'm trying to figure out a good
>way to store that data depending on the name of the field it belongs to.

Did you look at those functions I mentioned?

  #!/usr/bin/perl -w
  use strict;
  use CGI;

  # So you say you already know how to do this:
  my $q = new CGI;

  # But did you know you can also do this:

  my $line = $q->query_string();  # no newlines in $line
  my $q2 = new CGI $line;

The two objects $q and $q2 should be identical, except possibly for
file upload fields (I'm not sure about those).  

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Chunkachunkachunka'What?'chunkachunka'I SAID, "IT'S AN IMPACT PRINTER!"'
 chunka'OH, I THOUGHT YOU SAID IT WAS AN IMPACT PRINTER.'chunkachunka'THAT'S
 WHAT I SAID!'chunka'WHAT?'"                -- Kevin Martin in the monastery

Please ignore Godzilla and its pseudonyms - do not feed the troll.


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

Date: Tue, 27 Feb 2001 12:42:52 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: calculation of a size of the directory
Message-Id: <3A9B92BC.2183EC24@eed.ericsson.se>

Andrej Kartashov wrote:
> I try to use the following code for calculation of a size of the directory:
> *******************************************
> while(defined($file= <${DATADIR}/_qry/*>)){
> $catSize += -s $file}
> *******************************************
> 
> This working code but if we have many files in the directory then it takes very lot
> time....

You should better use opendir/readdir/closedir

> 
> Probably somebody has more beautiful idea, or any system command...

"man du" on UNIX

> This will work on Linux but it would be desirable that it worked on W2K as well...

poka
Alex


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

Date: Sun, 25 Feb 2001 11:27:52 -0500
From: Steve Attwell <s.attwell@snet.net>
Subject: Date formatting
Message-Id: <3A993288.634C5AF8@snet.net>

Is there any module that will convert data format mm/dd/yyyy to
DD-MMM-YY eg. 1/13/2001 == 13-JAN-01? I've looked in CPAN and perldoc.



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

Date: Tue, 27 Feb 2001 13:17:56 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Date formatting
Message-Id: <slrn99na7e.n9t.bernard.el-hagin@gdndev32.lido-tech>

On Sun, 25 Feb 2001 11:27:52 -0500, Steve Attwell <s.attwell@snet.net> wrote:
>Is there any module that will convert data format mm/dd/yyyy to
>DD-MMM-YY eg. 1/13/2001 == 13-JAN-01? I've looked in CPAN and perldoc.

You didn't look hard enough.

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Tue, 27 Feb 2001 09:00:46 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: Etymology of hash
Message-Id: <92cn9t4pg8td3kc6tr6ctnsat9thuhmbad@4ax.com>

--Still new to programming (but not computers) and  I am trying to
catch up.  I noticed that a hash goes by several names:

Associative Array
Dictionary (in Python anyway)

I am sure there are others.  I get what a hash is/does I was wondering
why it is called a hash:

Were they written like this once?

thing - key1
thing - key2
thing - key3

note dash (hash)...

Just wondering.


--
"> thanks in advance !!!
If you are going to do anything 'in advance' it should be RTFM."
       --swiped from a nobull clp.misc post

Lou Moran <lmoran@wtsg.com>


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

Date: 27 Feb 2001 12:51:13 +0000
From: nobull@mail.com
Subject: Re: form/cgi help really needed!
Message-Id: <u9y9usp9vi.fsf@wcl-l.bham.ac.uk>

shorty_helena@yahoo.se writes:

> Okay, so I realize this is really more of a html/form problem, but the form
> is outputted by a perl/cgi script and I haven't been able to get help from
> anywhere else...

Hmmm...
 
> WHAT I AM DOING:
> 
> - A cgi program searches through a stocklist and displays data about the found
> products: part #, quantity, price, manufacturer, date code, package.
> This is done with a foreach loop, and there could be any number of lines
> outputted.
> 
> - Quantity and price are in text fields, so the user can change them. 
> 
> - At the end of the line, there is a checkbox, which holds the values that are
> constant (part #, manufacturer, date code, package)
> 
> - The user is supposed to check the box at the end of the line with certain
> products, and if they want to, change quantity and price.
> 
> PROBLEM:
> 
> - Aaargh! It's all messed up!
> - No matter how many boxes you check, the information sent is:
>        * all price fields
>        * none of the quantity fields
>        * value of the checked boxes

Are you sure?  You are using the same field name for the quantity
field and the price field.  Maybe your form processing code (that you
don't show us) is only looking for the last value associated with each
field name.  I suggest using distinct and mnemonic names.
 
> QUESTION:
> 
> - Can I somehow make the checkbox apply to all the fields on the
> line??

I think not (not without client-side scripting).  Simply have your
script ignore the values returned in price/quatity fields for which
the corresponding checkbox is not checked.

> You can see the script in action at
> http://emelin.virtualave.net/searchystocky.htm
> (enter...let's say 0805J1000 or any random numbers...)
> 
> Relevant code:

[snip]

The sooner you get into "strict" the less painfull it will be when you
finally realise that you need to.

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


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

Date: Tue, 27 Feb 2001 11:18:59 GMT
From: Jerome Abela <Jerome.Abela@free.fr>
Subject: Re: How do I test whether a CODE reference is an NOP?
Message-Id: <3A9B8C16.2B6AD172@free.fr>

John Lin a écrit :
> if($code eq 'sub {}') { print 'defined but no operation' }
> # Pseudo code, of course, not working

use B::Deparse;
$deparse = B::Deparse->new();
if($deparse->coderef2text($code) eq $deparse->coderef2text(sub { })) {
print 'defined but no operation' }

> By the way, applying the same question, how do I test whether
> a CODE reference is doing 'exit'?

This checks whether the code contains the word 'exit' in any way
(string, function call, ...):
$deparse->coderef2text($code) =~ /\bexit\b/


Jerome.


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

Date: 27 Feb 2001 12:50:07 +0000
From: nobull@mail.com
Subject: Re: How the CLPM turns
Message-Id: <u9zof8p9xc.fsf@wcl-l.bham.ac.uk>

bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:

> 	After frequenting this newsgroup for over 2 years I've come to know
> some of the regular posters here and decided that, as a service to
> newbies, I'd write up some typical regular poster replies to typical
> newbie questions. That way someone new to the group can pick the style
> of answer he/she prefers and look for that person in the future.

Good idea - it should be included in the FAQ!

> Tad McClellan:
> 
> It's Perl or perl, not PERL (perldoc perlfaq1). You are expected to read
> the standard documentation that comes with your distribution of Perl
> before wasting the time of billions of people with a question you could
> have answered for yourself. This particular question could have been
> answered by simply doing:
> 
> perldoc -f sort

Actually Tad would probably be more likely to say '-q' not '-f',
although, of course, either will give the answer.

> Don't forget to enable warnings and strictures even when you're not
> writing in Perl. It's *that* important.

You missed out nobull:

As per Tad, but also...  

Unsent is a searchible resource.  Just because you are too slefish to
search it doesn't give you the right to inpare the ability of others to
search.  Before you post to a Usenet groups ask yourslef this: "If I
had bothered to do a search and saw a thread with the the same subject
line as I'm about to post would I be able to tell it was the same
question?"  If not the answer is "no" then do not post until you are
absolutely convinced you cannot make the answer "yes".

[ Note: typos above are deliberate self-parody ]

> __________
> 
> Godzilla!:
> 
> You male chauvinist pig! You dare attack mighty Kira with your mule manure!

"Mule manure"?  It that a reference to Kira's attacks on me?

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


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

Date: Tue, 27 Feb 2001 13:16:41 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: How the CLPM turns
Message-Id: <slrn99na53.n9t.bernard.el-hagin@gdndev32.lido-tech>

On 27 Feb 2001 12:50:07 +0000, nobull@mail.com <nobull@mail.com> wrote:
>bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:
>
>> 	After frequenting this newsgroup for over 2 years I've come to know
>> some of the regular posters here and decided that, as a service to
>> newbies, I'd write up some typical regular poster replies to typical
>> newbie questions. That way someone new to the group can pick the style
>> of answer he/she prefers and look for that person in the future.
>
>Good idea - it should be included in the FAQ!
>
>> Tad McClellan:
>> 
>> It's Perl or perl, not PERL (perldoc perlfaq1). You are expected to read
>> the standard documentation that comes with your distribution of Perl
>> before wasting the time of billions of people with a question you could
>> have answered for yourself. This particular question could have been
>> answered by simply doing:
>> 
>> perldoc -f sort
>
>Actually Tad would probably be more likely to say '-q' not '-f',
>although, of course, either will give the answer.
>
>> Don't forget to enable warnings and strictures even when you're not
>> writing in Perl. It's *that* important.
>
>You missed out nobull:

Actually, I missed out a lot of others, but I didn't want to test the
group's patience more than I had to. :-)

Oh, and I screwed up the subject (figures) which should be "As the CLPM
Turns" not "How the CLPM Turns". <shrug>

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Tue, 27 Feb 2001 13:16:50 GMT
From: "Koen Bossaert" <not@defined.com>
Subject: mod_perl script fail to execute correctly
Message-Id: <6NNm6.31$ri3.1979@nreader1.kpnqwest.net>

Hi,

I made this script and it works perfectly when I execute it in a terminal (I
work on RH6.2, apache 1.3.17, mod_perl 1.25), but in a browser the script
stops execution at the 'new' statement.  I also tried to make a seperate lib
of this script and called it from an other script but that didn't help.  No
errors seem to be displayed (on the screen or in the logs).  I didn't find
my answer in the FAQ, archives of this group nor in the mod_perl guide at
perl.apache.org  I must be doing something wrong, but can't figure out what
exactly.


use Apache::Registry;
use CGI;
use Registrant;
use ...

print "Content-type: text/html\n\n";
my $email = $cgi->param("email");
my $dbc = new DBConnection( ... );
$dbc->connect;

print "before new object<br>";
my $reg = new Registrant($dbc, $email);   <= execution stops here under
mod_perl
print "after new object<br>";
 ... some other code here
$dbc->disconnect;


I hope someone has experience with this kind of problems,

Koen



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

Date: Tue, 27 Feb 2001 12:40:26 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Off-topic: generating Excel _sheets_
Message-Id: <97g3kc$614$1@newsy.ifm.liu.se>

> But is there a way to generate an Excel file with
> several "sheets" (ie. small tabs at the bottom)?

Have you searched cpan?
/jN

--
 _____________________     _____________________
|   Jonas Nilsson     |   |                     |
|Linkoping University |   |      Telephone      |
|       IFM           |   |      ---------      |
| Dept. of Chemistry  |   | work: +46-13-285690 |
|  581 83 Linkoping   |   | fax:  +46-13-281399 |
|      Sweden         |   | home: +46-13-130294 |
|_____________________|   |_____________________|




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

Date: Tue, 27 Feb 2001 12:41:00 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Off-topic: generating Excel _sheets_
Message-Id: <3A9B924C.6A31713C@eed.ericsson.se>

Jonas Nilsson wrote:
> 
> > But is there a way to generate an Excel file with
> > several "sheets" (ie. small tabs at the bottom)?
> 
> Have you searched cpan?

Not yet - I'd prefer some HTML trick 
instead of generating binary Excel files


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

Date: Tue, 27 Feb 2001 12:00:06 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: Off-topic: generating Excel _sheets_
Message-Id: <3a9b9613.1741210@News.CIS.DFN.DE>

Ar Tue, 27 Feb 2001 11:17:31 +0100, do schriobh "Alexander Farber
(EED)" <eedalf@eed.ericsson.se>:
>I know that it's easy to generating an Excel 
>file from a CGI-script by sending the line:
>
>   print $query -> header (-type => 'application/vnd.ms-excel');
>
>and then just an HTML-file with HTML-table 
>(you can even have colored backgrounds).
>
>But is there a way to generate an Excel file with 
>several "sheets" (ie. small tabs at the bottom)?

If you save a multi-sheet workbook as HTML in Excel 2000 you will see
how Excel achieves a tabbed effect. However, the generated HTML is
hairy and it also requires a style sheet.

If you are interested, the Excel HTML specification is here:
http://msdn.microsoft.com/library/officedev/ofxml2k/ofxml2k.htm 

Alternatively, you could use the Spreadsheet:WriteExcel module to
generate a native Excel binary file:

    #!/usr/bin/perl -w

    use strict;
    use Spreadsheet::WriteExcel;

    # Create a new Excel workbook
    my $workbook = Spreadsheet::WriteExcel->new("multi.xls");

    # Add some worksheets
    my $worksheet1 = $workbook->addworksheet();
    my $worksheet2 = $workbook->addworksheet();

    $worksheet1->write(0, 0, "Hello");
    $worksheet2->write(0, 0, "World");


See http://search.cpan.org/search?dist=Spreadsheet-WriteExcel
There is a CGI example in the distro.

John.
-- 
All your base are belong to us. 




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

Date: Tue, 27 Feb 2001 12:52:45 -0000
From: "Terry" <dcs@ntlworld.com>
Subject: OT unwanted exclamation marks
Message-Id: <5tNm6.1076$OL.37961@news6-win.server.ntlworld.com>

Hi

I don't think this is actually a perl\cgi problem but hopefully somebody has
come across this before and can help:-)

I am using sendmail to send html email. I keep getting unwanted exclamation
marks appearing in the resulting emails. The example I am giving is rather
long so have placed it here
http://dcsite.hypermart.net/test.html

Any comments\help would be greatly appreciated

Many thanks

Terry




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

Date: Tue, 27 Feb 2001 13:19:15 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: OT unwanted exclamation marks
Message-Id: <slrn99na9u.n9t.bernard.el-hagin@gdndev32.lido-tech>

On Tue, 27 Feb 2001 12:52:45 -0000, Terry <dcs@ntlworld.com> wrote:
>Hi
>
>I don't think this is actually a perl\cgi problem but hopefully somebody has
>come across this before and can help:-)

Well I've got a nasty itch on my back *just* where I can't reach it. I'm
hoping that maybe someone has had a similar experience and could help
me.

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Tue, 27 Feb 2001 13:30:44 -0000
From: "Terry" <dcs@ntlworld.com>
Subject: Re: OT unwanted exclamation marks
Message-Id: <N0Om6.1197$OL.44067@news6-win.server.ntlworld.com>

From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>

> On Tue, 27 Feb 2001 12:52:45 -0000, Terry <dcs@ntlworld.com> wrote:
> >Hi
> >
> >I don't think this is actually a perl\cgi problem but hopefully somebody
has
> >come across this before and can help:-)
>
> Well I've got a nasty itch on my back *just* where I can't reach it. I'm
> hoping that maybe someone has had a similar experience and could help
> me.
>
You'll go far Bernard ;-)







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

Date: Tue, 27 Feb 2001 06:49:50 -0500
From: Knight Rider <knightrid@SPAMSUXhotmail.com>
Subject: Re: Perl CGI and Apache under Win98/NT
Message-Id: <qs4n9tsdnhpjhqj7f6u1fcvrddnr4omg8j@4ax.com>

Dunno if this will help or not, but I am running Apache also to try
and build a web site.  You have to edit the httpd.conf file in the
conf directory and set the cgi-bin path
 
    ScriptAlias /cgi-bin/ "C:/trialweb/cgi-bin/"

    #
    # "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed
to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "C:/trialweb/cgi-bin">


you seem to be able to run EXE, while I cant - LOL, but all cgi
programs work fine.  PM or PL programs dont seem to ork either, but I
think I have to set each up individually.
 
Hope this helps

          Laid Her
        Knight Rider

On Tue, 27 Feb 2001 11:55:36 +0100, "Narcyz Knap" <knap@firma.2p.pl>
wrote:

>Could you please help me guys. I have installed Apache Server under Win98
>and also Win2000 in order to test Perl CGI scripts locally. I set up the
>Server Name as 127.0.0.1 and it seems to go on just fine. I can even test
>cgi "exe" file that reports the environment variables. However my perl cgis
>do not seem to cooperate with Apache server. When I boot them manually
>they work just fine. Under Apache I get the error message announcing a
>misconfiguration problem. I have even tried an alternative web eserver
>program called Xitami, and get the same problem. Please help!!!!!!
>
>



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

Date: 27 Feb 2001 08:26:22 -0500
From: wfeidt@his.com (Bill Feidt)
Subject: Perl program review request
Message-Id: <90555FD99wfeidthiscom@216.200.68.12>

If folks would care to review and comment on my most
recent Perl programming effort, I'd be pleased to have
the input.  clpm has been a wonderful learning tool 
for me, even though I normally only lurk.  Thank you
all for being here and for sharing your wisdom and
experience.

Program: 

  http://www.cpcug.org/dialup/shdisk.txt

The program creates this file as its output:

  http://www.cpcug.org/dialup/diskfree.html

The program's source information database is structured 
like this:

20010225|/|53%
20010225|/usr|73%
20010225|/var|69%
20010225|/local|83%
20010225|/homeb|69%
20010225|/homec|69%
20010225|/homed|72%
20010225|/tmp|0%
20010226|/|53%
20010226|/usr|73%
20010226|/var|72%
20010226|/local|84%
20010226|/homeb|69%
20010226|/homec|69%
20010226|/homed|72%
20010226|/tmp|0%
[...]

It is run daily as a cronjob after the source database
has been updated.

TIA,

Bill
Bill@ng3k.com


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

Date: Tue, 27 Feb 2001 09:56:43 -0000
From: "xu palo" <xu@redbird.co.uk>
Subject: Re: perl/CGI question
Message-Id: <97ft4v$4l2$1@newsg3.svr.pol.co.uk>

You could try to `include' script.pl as a subroutine which
gets called at the end of your first script.

Hope this helps,
xu

"ted" <tlav1@mediaone.net> wrote in message
news:3A9B08EB.824F8F3F@mediaone.net...
> An Internal Server error seems to imply that there is something wrong in
> second script you're trying to exec.  I don't know how much help I can be
> with the few details you've provided, but you can try something like
> this...
>
> $myscript = "/path/to/your/script.pl";
>
> system("$myscript") or die "cannot system call $myscript\n\$!\n";
>
> ...or you can try the backtick operator...
>
> `./myscript.pl` or die "cannot run myscript.pl\n\$!\n";
>
> These are just guesses.  Hope one works for you.
>
> ted
>
>
>
>
> teknokrat wrote:
>
> > I would like to execute a new perl script at the end of a CGI script
> > using exec("perl script.pl\n"). Unfortunatelt this give me an internal
> > server error - does anyone know how this can be done?
> >
> > The reason i want to do this is so that the web user doesn't have to
> > wait ages for the second script to complete.
> >
> > thanks
>




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

Date: Mon, 26 Feb 2001 14:19:31 -0600
From: Steve Wells <wells@cedarnet.org>
Subject: Re: perl/CGI question
Message-Id: <3A9ABA53.BB52BCF@cedarnet.org>

Of course you probably want to use system() as opposed to exec()
and run your second program in the background.

ie] system("script.pl&");

however...

------------------------------------------------------------------
WARNING: This is not specifically a perl answer but it may help.
------------------------------------------------------------------

If your server supports it you may want to use non-parsed headers instead.

Then quickly output the page and do the "work" on the backend.  The server

recognizes the nph program by the filename: nph-FILE.  As long as the file

starts with 'nph-' the server doesn't buffer the information. One obvious
use
for nph- is for logging where you want to quickly display something and
then
take your time logging the information.  I have even used nph- headers
when
I wanted some interactivity while performing a long process.

See: http://www.price-hunter.net/ (the source is downloadable)

Here's a simple perl example of a nph script:

nph-example.cgi (observe that the filename starts with 'nph-')
---------------
#!perl
use strict;

use CGI;
my $q = new CGI;

# don't allow perl to buffer either
   select((select(STDOUT), $|=1)[0]);

# output our headers (notice -nph => 1)
   print $q->header( -type => 'text/plain',
                               -nph => 1 );

# immediatly print this
   print "hello world\n";

# in 20 seconds print this
  sleep(20);
   print "foo\n";

# 5 more seconds
   sleep(5);
   print "bar\n";

exit 1;
------------------------

hth,
STEVE

teknokrat wrote:

> I would like to execute a new perl script at the end of a CGI script
> using exec("perl script.pl\n"). Unfortunatelt this give me an internal
> server error - does anyone know how this can be done?
>
> The reason i want to do this is so that the web user doesn't have to
> wait ages for the second script to complete.
>
> thanks



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

Date: Tue, 27 Feb 2001 13:52:31 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <qdbn9tkkaac2hf98ja50bfp87sfus3bnf7@4ax.com>

Brad Baxter wrote:

>And below is a preliminary stab at it.  Line 18 is there to get around an
>apparent bug in my version of Interpolation.pm.

>    18  *get_colour = *get_couleur = *get_colore = *get_color;
>    19
>    20  use Interpolation
>    21      color      => \&get_color,
>    22      colour     => \&get_colour,
>    23      la_couleur => \&get_couleur,
>    24      colore     => \&get_colore,
>    25      ;

Unfortunately it's not the only bug in Interpolation.pm. For example,
this will fail, too:

	sub foo { shift }
	use Interpolation 'FOO' => \&foo;
	use Interpolation 'FOO' => \&foo;
-->
Values in argument list in `use Interpolation' must be code refs;
aborting
BEGIN failed--compilation aborted 

Perhaps it even has the same cause...

The bug you are referring to, is because this module uses the original
code ref as the tied object(!), so you can't use the same sub for more
than one hash. One more indirection gets around it: I bless the scalar
containing the code ref, not the code ref itself:

	sub TIEHASH {
	    my $pack = shift;
	    my $cref = shift;
	    ref $cref) or croak "'$cref' no a code ref; aborting";
	    bless \$cref, $pack;
	}

	sub FETCH {
	    &{${shift()}};
	}

I really don't like the interface to this module. There is no reason to
hide an elegant "tie" under an ugly "use" interface -- with a hidden
symbolic reference to a global hash as well -- ugh!

Fortunately, this works too.

	use Interpolation;
	my %FOO;
	tie %FOO, Interpolation, \&foo;
	sub foo {
	    return "<#@_#>";
	}
	print "This line contains a $FOO{bar}.";
-->
	This line contains a <#bar#>.

Look, ma: a lexical hash!

-- 
	Bart.


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

Date: Tue, 27 Feb 2001 11:53:15 GMT
From: Ted Fiedler <tfiedler@zen.moldsandwich.com>
Subject: sending to sockets
Message-Id: <Pine.LNX.4.21.0102270650150.18443-100000@zen.moldsandwich.com>

Ive been working on this for several hours and CANNOT seem to figure out
what im doing wrong - all I want to do is get the output from the socket
and write it to a file. any help is appreciated.

use strict;
use IO::Socket;

######################################################
#            Configs go here                         #
######################################################
#
#
my ($remote_host);
my ($remote_port);
my ($protocol);
#
# $protocol="udp";
$protocol="tcp";
$remote_port="23"; # or whatever
$remote_host="rainmaker.wunderground.com"; # this should usually be the
same???
######################################################
#           End user configs                         #
######################################################



######################################################
#              constants                             #
######################################################
#
my ($socket);
my ($awnser);
#
######################################################
#                   End of Constants                 #
######################################################

open(WEATHERFILE, ">weather.dat") || die "couldnt open weather.dat";

$socket = IO::Socket::INET->new(PeerAddr => $remote_host,
                                PeerPort => $remote_port,
                                Proto    => $protocol,
                                Type     => SOCK_STREAM);
sleep 5;
print $socket "\r";
sleep 10;
$awnser=<$socket>;
print WEATHERFILE "$awnser";
print $socket "bgm\r";
$awnser=<$socket>;
print WEATHERFILE "$awnser";
sleep 3;
print $socket "x";
sleep 2;
print $socket "\r";
close ($socket);
close WEATHERFILE;

******FYI -- This is the out put that I get in weather.dat ******
------------------------------------------------------------------------------
^M*               Welcome to THE WEATHER UNDERGROUND telnet
service!           *


Thanks in advance 

Ted



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

Date: Tue, 27 Feb 2001 14:15:54 +0100
From: H. Camphausen <h.camp@scm.de>
Subject: Re: Somewhat complicated hash from DB question
Message-Id: <97g925$apk$1@surz18.uni-marburg.de>

[F'up zu Brian's Posting vom Mon, 26 Feb 2001 20:41:32 -0500]

> I'm trying to create a hash from a database read.  I'm nesting the hash
> using a couple of fields from the database and a counter.  I've been messing
> around but can't get it to work.  I want to be able to populate it and then
> read it...

<hint>
If you are going to handle deeply nested data structures, maybe the 
module Data::Iterator could be useful. You can get it from CPAN.
POD included.
</hint>


hth + mfg, Hartmut

-- 
CREAGEN Computerkram     Fon: 06422/850527
Hartmut Camphausen       Fax: 06422/850528
Am kleinen Born 1        E-Mail: h.camp@creagen.de
35287 Amöneburg          WWW: http://www.creagen.de


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

Date: 27 Feb 2001 12:49:59 +0000
From: nobull@mail.com
Subject: Re: timeout connect() with select?
Message-Id: <u91yskqoi0.fsf@wcl-l.bham.ac.uk>

"h." <perlCHEESE@CHEESEatlaswebmail.com> writes:

>   I need to timeout a Socket connect() to a POP3 server.

The constructor takes a timeout argument which it propagates to
IO::Socket... oh, oops, sorry you aren't using Net::POP3.

> I know how to do it using alarm(), but I'd much rather use the more
> reliable and more widely supported select() call.

Even if you have decided to re-invent the wheel you can help yourself
by looking at existing wheels.  In Perl 5.6 the IO::Socket module uses
IO::Select to implement connect() timeouts.  If you really must use a
low-level Socket connect rather than an IO::Socket::INET (or better
still Net::POP3) connect you can crib the code from IO::Socket.

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


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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