[14055] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1465 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 23 09:07:26 1999

Date: Tue, 23 Nov 1999 06: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)
Message-Id: <943365912-v9-i1465@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 23 Nov 1999     Volume: 9 Number: 1465

Today's topics:
    Re: Assigning an element of n associat. array to a scal <i@moe.co.uk>
    Re: Assigning an element of n associat. array to a scal <gellyfish@gellyfish.com>
        binarie operators like and & or .. <duthler@tebenet.nl>
    Re: Call for Programs: the "phonecode" benchmark (Ian Collier)
        cgi_mail to 2 ppl at once vod@writemail.com
    Re: cgi_mail to 2 ppl at once <gellyfish@gellyfish.com>
        Compiling Perl , Solaris 2.6 and Ultra 5 (Philippe Debroux)
    Re: Core dump in Perl_my_pclose (Peter Heimann)
    Re: Help with TCP sockets please marius_13@my-deja.com
        How to send CTRL characters over telnet session ? <pascal.masuit@netbuilding.simac.be>
        Mail Server - Automatic Account Setup <Roland@psychenet.co.uk>
        relation of cgi scripts and STDOUT (??) <lzu99dk@rdg.ac.uk>
        relation of cgi scripts and STDOUT (??) <lzu99dk@rdg.ac.uk>
        Serial port communication in WinNT?? <citidancer@hongkong.com>
    Re: Serial port communication in WinNT?? <gellyfish@gellyfish.com>
    Re: Serial port communication in WinNT?? (Bbirthisel)
    Re: Simple help <mcts@backwoods.org>
    Re: Simple help <gellyfish@gellyfish.com>
        simple question for CGI and STDOUT <lzu99dk@rdg.ac.uk>
        simple question for CGI and STDOUT <lzu99dk@rdg.ac.uk>
        simple question for CGI and STDOUT <lzu99dk@rdg.ac.uk>
    Re: simple question for CGI and STDOUT (Simon Cozens)
    Re: simple question for CGI and STDOUT <gerglery@usa.net>
    Re: simple question for CGI and STDOUT <gellyfish@gellyfish.com>
    Re: simple question for CGI and STDOUT (Matthew Bafford)
    Re: Simple question (Martien Verbruggen)
    Re: Simple question <flavell@mail.cern.ch>
        what is the equivilant in perl? <plaven@idl.net.au>
    Re: what is the equivilant in perl? <dgarstan@nsw.bigpond.net.au>
    Re: what is the equivilant in perl? (Simon Cozens)
    Re: what is the equivilant in perl? (Matthew Bafford)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 23 Nov 1999 12:24:58 -0000
From: "Imo" <i@moe.co.uk>
Subject: Re: Assigning an element of n associat. array to a scalar variable
Message-Id: <BGv_3.155$R72.17899@newnews.dircon.co.uk>

$user_name = $hash{'name'};

Is that what is meant?

Imo

Andrew Bleakley <pullen@one.net.au> wrote in message
news:383a63ee@pink.one.net.au...
> I have parsed the information from a form and assigned the name/value
pairs
> to assoc. array formdata.
> I then need to assign the value associated with 'name' to variable called
> $user_name. I cannot seem to make the assignment. Any help would be
> appreciated.
>
>
>




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

Date: 23 Nov 1999 12:33:03 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Assigning an element of n associat. array to a scalar variable
Message-Id: <383a897f_2@newsread3.dircon.co.uk>

<even Outlook Express lets you put the reply in the right place - fixed>

Imo <i@moe.co.uk> wrote:
> Andrew Bleakley <pullen@one.net.au> wrote in message
> news:383a63ee@pink.one.net.au...
>> I have parsed the information from a form and assigned the name/value
> pairs
>> to assoc. array formdata.
>> I then need to assign the value associated with 'name' to variable called
>> $user_name. I cannot seem to make the assignment. Any help would be
>> appreciated.
>>
> $user_name = $hash{'name'};
> 
> Is that what is meant?
> 

Well except that it would be

  $user_name = $formdata{name};

But I want to know what he means by 'cannot seem to make the assignment'
maybe the = key on his keyboard is broken ...

/J\
-- 
"I can't believe Elton John recorded that song again. Exactly how do you
live your life like a spurgis in the wind?" - Ronnie, Veronica's Closet


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

Date: Tue, 23 Nov 1999 13:01:08 +0100
From: "jan smit" <duthler@tebenet.nl>
Subject: binarie operators like and & or ..
Message-Id: <81dvce$939$1@porthos.nl.uu.net>

how can i compare bits in things ..like
$something = "a";
$something2 = $something & 0x80;

that kinda stuff ..loolol .. could someone help me .. cuz im screwing up
 ..loolol





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

Date: 23 Nov 1999 12:57:39 GMT
From: imc@comlab.ox.ac.uk (Ian Collier)
Subject: Re: Call for Programs: the "phonecode" benchmark
Message-Id: <20691-ovate.imc@comlab.ox.ac.uk>

Uri Guttman wrote:
>                                             if someone here were to
> start a thread on a solution, maybe we could do a group coding in perl
> golf mode or something like that. kick some other languages butt's like
> in the practice of programming (perl had the shortest code by far and
> 2nd fastest run time).

Then Alex Rhomberg posted a solution.

Careful.  We should wait for the results before saying how wonderful
Perl is.  But, as a bit of ammunition for the other side...

My submission in one of the other languages*, which took 40 minutes to
write (including the block comments) and 6 minutes to debug (two typos
and a function with arguments in the wrong order - nothing actually wrong
with the algorithm), contains 53 lines and 1216 bytes after removal of
the comments and leading spaces.  The Perl program just posted contains
46 lines and 1191 bytes.  But at least 10 of the lines (235 bytes) in my
program are for error checking.  I also like to think my version is easier
to understand.

Perl wins on run time, but only by a factor of 2.
--
* which I won't name to avoid causing a war, though you could
  easily guess with a tiny bit of research
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page below
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml


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

Date: Tue, 23 Nov 1999 13:18:18 GMT
From: vod@writemail.com
Subject: cgi_mail to 2 ppl at once
Message-Id: <81e46m$q8i$1@nnrp1.deja.com>

#!/usr/bin/perl

require "../cgi-lib.pl";

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Things that may have to changed
my $sendmail = "/bin/sendmail";
my $mailTo = "tellmeall\@usa.net";
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Hash that will hold the <form> input
my %FORM ;

# -=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-= -=-=-=-=-=-=-= -=-=-=-=-=-
# Call cgi-lib.pl func ReadParse  read the Form input un-webify it
&ReadParse(\%FORM);

$timeNow = localtime;
print PrintHeader();

open (MAIL,"| $sendmail $mailTo") || die "ERROR * Could not open
$sendmail\n";
print MAIL "From: ghost\n
Subject: Important;

foreach $key (keys %FORM) {
	print MAIL "$key = $FORM{$key}\n";
}
close (MAIL);

print "Thank you and bla bla bla";


I hace this script i wanna send this to 2 ppl at one time
so please help me and tell me how i can do it
i am new to PERL


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 23 Nov 1999 13:57:21 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: cgi_mail to 2 ppl at once
Message-Id: <383a9d41_1@newsread3.dircon.co.uk>

vod@writemail.com wrote:
> #!/usr/bin/perl
> 

No -w there ...

> require "../cgi-lib.pl";
> 

I would truly recommend using CGI.pm - it even has a cgi-lib compatibility
mode ....

> # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> # Things that may have to changed
> my $sendmail = "/bin/sendmail";
> my $mailTo = "tellmeall\@usa.net";

If you put that it single quotes you wouldnt need to escape the @

> # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> # Hash that will hold the <form> input
> my %FORM ;
> 
> # -=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-= -=-=-=-=-=-=-= -=-=-=-=-=-
> # Call cgi-lib.pl func ReadParse  read the Form input un-webify it
> &ReadParse(\%FORM);
> 
> $timeNow = localtime;
> print PrintHeader();
> 
> open (MAIL,"| $sendmail $mailTo") || die "ERROR * Could not open

I would read the sendmail manpage - with particular reference to the '-t'
switch - If you have further questions about sendmail you would be better
off addressing them to comp.mail.sendmail

> $sendmail\n";
> print MAIL "From: ghost\n
> Subject: Important;
> 
> foreach $key (keys %FORM) {
> 	print MAIL "$key = $FORM{$key}\n";
> }
> close (MAIL);
> 

You will want to check the result of the close as this will enable you
to determine if sendmail experienced an error - see the perlfunc entry
for close() for more on this .

> print "Thank you and bla bla bla";
> 
> 
> I hace this script i wanna send this to 2 ppl at one time
> so please help me and tell me how i can do it
> i am new to PERL
> 

If you read the sendmail manpage as I said above then all should become
clear.


/J\
-- 
"My codpiece layeth awkwardly across the nadgers" - Declan Donnelly


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

Date: Tue, 23 Nov 1999 14:43:18 +0100
From: Debroux@sri.ucl.ac.be (Philippe Debroux)
Subject: Compiling Perl , Solaris 2.6 and Ultra 5
Message-Id: <Debroux-ya023380002311991443180001@news.sri.ucl.ac.be>

Hi,

I'm running Solaris 2.6 5/98 on a Sun Sparc Ultra 5. I've installed all the
Solaris 2.6 recommended patches. When I try to compile Perl5.005_03 (with
gcc 2.8.1), I get the message :

Writing Makefile for DynaLoader
mkdir ../../lib/auto/DynaLoader
 ../../miniperl -I../../lib -I../../lib -I../../lib -I../../lib
DynaLoader_pm.PL DynaLoader.pm
cp DynaLoader.pm ../../lib/DynaLoader.pm
AutoSplitting ../../lib/DynaLoader.pm (../../lib/auto/DynaLoader)
cp dl_dlopen.xs DynaLoader.xs
 ../../miniperl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp
-noprototypes -typemap ../../lib/Ex
tUtils/typemap DynaLoader.xs >xstmp.c && mv xstmp.c DynaLoader.c
gcc -c  -I/usr/local/include -O     -DVERSION=\"1.03\" 
-DXS_VERSION=\"1.03\"  -I../.. -DPERL_CORE -
DLIBC="/lib/libc.so" DynaLoader.c
DynaLoader.c: In function `XS_DynaLoader_dl_load_file':
DynaLoader.c:165: array subscript is not an integer
DynaLoader.c:165: array subscript is not an integer
DynaLoader.c:165: array subscript is not an integer
DynaLoader.c: In function `XS_DynaLoader_dl_find_symbol':
DynaLoader.c:198: array subscript is not an integer
DynaLoader.c:198: array subscript is not an integer
DynaLoader.c:198: array subscript is not an integer
DynaLoader.c:198: array subscript is not an integer
DynaLoader.c: In function `XS_DynaLoader_dl_install_xsub':
DynaLoader.c:241: array subscript is not an integer
DynaLoader.c:241: array subscript is not an integer
DynaLoader.c:241: array subscript is not an integer
*** Error code 1
make: Fatal error: Command failed for target `DynaLoader.o'
Current working directory /usr/local/src/perl5.005_03/ext/DynaLoader
*** Error code 1
make: Fatal error: Command failed for target `lib/auto/DynaLoader/DynaLoader.a'


And in DynaLoader.c:165, I find

flags = (int)SvIV(ST(0.999999999999984));

I think it should be 1... and not 0.999999999999984...

Any idea what's going wrong ?

Thanks in advance.

Philippe


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

Date: 23 Nov 1999 13:17:15 GMT
From: peter@i3.informatik.rwth-aachen.de (Peter Heimann)
Subject: Re: Core dump in Perl_my_pclose
Message-Id: <81e44r$bq0$1@nets3.rz.RWTH-Aachen.DE>

In <Pine.GSO.4.10.9911221547550.16575-100000@user2.teleport.com> Tom Phoenix <rootbeer@redcat.com> writes:

>Moving the alarm line to after the open seems to fix the problem. 

Thanks for the hint. On my system, it seems to fix it, too.

-- 
Peter Heimann            peter@i3.informatik.rwth-aachen.de


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

Date: Tue, 23 Nov 1999 12:41:24 GMT
From: marius_13@my-deja.com
Subject: Re: Help with TCP sockets please
Message-Id: <81e21k$otk$1@nnrp1.deja.com>

In article <81cdjl$kf3$1@nnrp1.deja.com>,
  koverton@my-deja.com wrote:
> A quick question Marius (I'm doing similar stuff right now, so maybe
we
> can help each other out): have you telnetted to your server's port to
> see if you can communicate that way?  That's my preferred way of
testing
> this stuff and I find it works pretty well.
>

Yes, I have telneted to my server, and have worked out the issues
there.  The problem i'm having now, is on the client.  I open the
socket, and I'm having trouble trying to write to the socket on the
client side.

Brian


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 23 Nov 1999 12:57:47 +0100
From: "Pascal Masuit" <pascal.masuit@netbuilding.simac.be>
Subject: How to send CTRL characters over telnet session ?
Message-Id: <81dvof$nun$1@xenon.inbe.net>

Hi all,

Has anyone got experience in sending control characters to a router over a
telnet session ?
If so, I would appreciate it if you could give me an example of the print
statement !

FYI: I'm using Expect.pm v1.07, Perl 5.002 on HP-UX 10.20

I'm trying to send a CTRL-P to an IBM 2210 router to get in the root menu.
I've tried everything I could come up with...
print $telnet "\020\r\n";
print $telnet "\020\r";
print $telnet "\020\n";
print $telnet '\020\r';
print $telnet "\\20\r\n";
print $telnet "\\020\r";
print $telnet "\cP\r\n";
print $telnet "\cP\r";
print $telnet "\cP\n";
print $telnet "\cP";
 .. but was unsuccessful so far: the router does not accept the CTRL-P
command. After sending the CTRL-P, a new non-root prompt is matched,
and I fail to get in the root menu.

In debug mode, I've noticed that the commands that I send to the router
are quoted differently than I meant them to be.
For instance:   print $telnet "logout";
is in debug mode send to STDOUT as: 'logout'.
I am afraid that the same occurs with the CTRL characters and in that case
the backslash will loose it's special meaning:
'\020' is just that: backslash, zero, two, zero
"\020" is CTRL-P (octal 20)
However, I doubt this is the case here since the author writes about sending
CTRL characters to the device.

Has anyone been confronted with this issue ?
Thanks in advance for sharing your thoughts.

Pascal Masuit





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

Date: Tue, 23 Nov 1999 12:34:24 -0000
From: "Roland Corbet" <Roland@psychenet.co.uk>
Subject: Mail Server - Automatic Account Setup
Message-Id: <383a8aef.0@news.myratech.net>

I need to be able to have a mail server running on an NT Server.  The users
of the mail server need to be administered (add, configure and delete) by
scripts - preferably Perl.

Could anoyone suggest a Mail Server that supports this?  Would MS Exchange
Mail Server do the job?

TIA for any information that you can give.

Regards

Roland Corbet (Roland@psychenet.co.uk)
Systems Administrator
Psyche Solutions LTD




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

Date: Sat, 20 Nov 1999 19:45:19 +0000
From: Dimitrios Kremmydas <lzu99dk@rdg.ac.uk>
Subject: relation of cgi scripts and STDOUT (??)
Message-Id: <3836FA4E.7F1E6B02@rdg.ac.uk>

if i close the STDOUT (close(STDOUT)), does the script kill itself ???
if yes, how can i make the browser stop waiting for any more input from
the script while the script will keep running ?

cheers


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

Date: Sat, 20 Nov 1999 19:46:37 +0000
From: Dimitrios Kremmydas <lzu99dk@rdg.ac.uk>
Subject: relation of cgi scripts and STDOUT (??)
Message-Id: <3836FA9D.320A48D7@rdg.ac.uk>

if i close the STDOUT (close(STDOUT)), does the script kill itself ???
if yes, how can i make the browser stop waiting for any more input from
the script while the script will keep running ?

cheers


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

Date: Tue, 23 Nov 1999 21:08:23 +0800
From: "Calvin" <citidancer@hongkong.com>
Subject: Serial port communication in WinNT??
Message-Id: <81e3a2$gcn$1@hfc.pacific.net.hk>

Hi,
    Is there any tutorial online which teach people how to work with the
serial ports in WinNT using perl???
Thanks
Best regards
Calvin




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

Date: 23 Nov 1999 13:16:41 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Serial port communication in WinNT??
Message-Id: <383a93b9_2@newsread3.dircon.co.uk>

Calvin <citidancer@hongkong.com> wrote:
> Hi,
>     Is there any tutorial online which teach people how to work with the
> serial ports in WinNT using perl???
> 

There is a module Win32::Serial that has probably got reasonable 
documentation .. The module is at CPAN but the authors homepage
for it is at : <http://members.aol.com/bbirthisel/alpha.html>

/J\
-- 
"The most frightening thing on television since Anthea Turner revealed
she had a sister" - Suggs


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

Date: 23 Nov 1999 13:23:43 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Serial port communication in WinNT??
Message-Id: <19991123082343.09996.00001172@ng-fq1.aol.com>

Hi Calvin:

>  Is there any tutorial online which teach people how to work with the
>serial ports in WinNT using perl???

The article from The Perl Journal #13 is online - but you need to be
a subscriber to get to it. There are a number of examples included
in the Win32::SerialPort distribution (CPAN) and a few more on
my site:

    http://members.aol.com/bbirthisel/alpha.html

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Tue, 23 Nov 1999 07:22:38 -0500
From: MC <mcts@backwoods.org>
Subject: Re: Simple help
Message-Id: <383A870E.E1D9CBD0@backwoods.org>



Larry Rosler wrote:
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> $_ = '    9912345  John Q.  Public III    87';
> 
> / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
> 

try
/ 99(\d+)\s+(.+\S) +\d+/ and print "|99$1 $2|\n";

> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com

-- 
--==[ Ğetroit to the SuperBowl ]==--

Time is nature's way of keeping
everything from happening at once

Question Reality


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

Date: 23 Nov 1999 12:35:58 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Simple help
Message-Id: <383a8a2e_2@newsread3.dircon.co.uk>

In comp.lang.perl.misc MC <mcts@backwoods.org> wrote:
> 
> Larry Rosler wrote:
>> 
>> #!/usr/local/bin/perl -w
>> use strict;
>> 
>> $_ = '    9912345  John Q.  Public III    87';
>> 
>> / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
>> 
> 
> try
> / 99(\d+)\s+(.+\S) +\d+/ and print "|99$1 $2|\n";
> 

I might be going stupid here but isnt that what Larry said ?

/J\
-- 
"What is the future for beef? Curtains?" - Graham Norton


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

Date: Sat, 20 Nov 1999 19:42:14 +0000
From: Dimitrios Kremmydas <lzu99dk@rdg.ac.uk>
Subject: simple question for CGI and STDOUT
Message-Id: <3836F995.77C6CDE9@rdg.ac.uk>

if i close the STDOUT (close(STDOUT)), does the script kill itself ???
if yes, how can i make the browser stop waiting for any more input from
the script while the script will keep running ?

cheers


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

Date: Sat, 20 Nov 1999 19:31:36 +0000
From: Dimitrios Kremmydas <lzu99dk@rdg.ac.uk>
Subject: simple question for CGI and STDOUT
Message-Id: <3836F718.98C9B952@rdg.ac.uk>

if i close the STDOUT (close(STDOUT)), does the script kill itself ???
if yes, how can i make the browser stop waiting for any more input from
the script while the script will keep running ?

cheers


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

Date: Sat, 20 Nov 1999 19:43:26 +0000
From: Dimitrios Kremmydas <lzu99dk@rdg.ac.uk>
Subject: simple question for CGI and STDOUT
Message-Id: <3836F9DE.80E9C22D@rdg.ac.uk>

if i close the STDOUT (close(STDOUT)), does the script kill itself ???
if yes, how can i make the browser stop waiting for any more input from
the script while the script will keep running ?

cheers


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

Date: 23 Nov 1999 11:31:08 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: simple question for CGI and STDOUT
Message-Id: <slrn83kuns.3i8.simon@othersideofthe.earth.li>

Dimitrios Kremmydas (comp.lang.perl.misc):
>if i close the STDOUT (close(STDOUT)), does the script kill itself ???
>if yes, how can i make the browser stop waiting for any more input from
>the script while the script will keep running ?

Dimitrios, you posted this 5 times. Once was enough. :)

No, it won't make the script terminate. However, because of the way the
server calls a CGI script, it will wait until the process has
terminated. Even if the CGI script forks, I think it will wait for its
children. I'm not actually sure how you would continue running after
producing the page, but if you ask the nice people in
comp.infosystems.www.authoring.cgi, they'd be pleased to tell you.

-- 
Intel CPUs are not defective, they just act that way.
		-- Henry Spencer


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

Date: 23 Nov 1999 11:49:20 +0000
From: Alternative Fluffy <gerglery@usa.net>
Subject: Re: simple question for CGI and STDOUT
Message-Id: <87903pwhq7.fsf@banet.net>

Simon Cozens <simon@brecon.co.uk> wrote:

> Dimitrios Kremmydas (comp.lang.perl.misc):
>> if i close the STDOUT (close(STDOUT)), does the script kill itself ???
>> if yes, how can i make the browser stop waiting for any more input from
>> the script while the script will keep running ?

> Dimitrios, you posted this 5 times. Once was enough. :)

> No, it won't make the script terminate. However, because of the way the
> server calls a CGI script, it will wait until the process has
> terminated. Even if the CGI script forks, I think it will wait for its
> children. I'm not actually sure how you would continue running after
> producing the page, but if you ask the nice people in
> comp.infosystems.www.authoring.cgi, they'd be pleased to tell you.

Actually I think this really is a Perl question.  A FAQ, but at least
a Perl FAQ.

Dimitrios, see

	perldoc -q daemon

[that is, the question "How do I fork a daemon process?" in perlfaq8].

The technique decribed there should be adaptable to what you
described.  Now, if what you described is really what you want is
another question, but what the heck.


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

Date: 23 Nov 1999 11:50:33 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: simple question for CGI and STDOUT
Message-Id: <383a7f89_1@newsread3.dircon.co.uk>

Simon Cozens <simon@brecon.co.uk> wrote:
> Dimitrios Kremmydas (comp.lang.perl.misc):
>>if i close the STDOUT (close(STDOUT)), does the script kill itself ???
>>if yes, how can i make the browser stop waiting for any more input from
>>the script while the script will keep running ?
> 
> Dimitrios, you posted this 5 times. Once was enough. :)
> 
> No, it won't make the script terminate. However, because of the way the
> server calls a CGI script, it will wait until the process has
> terminated. Even if the CGI script forks, I think it will wait for its
> children. 
> 

This latter is not true - if the program forks, the child closes its
STDOUT, and the parent exits then the server will drop the connection to
the browser.

/J\

-- 
"Michael Ancram, you haven't got a hope in hell of winning the next
election" - Huw Edwards, BBC News


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

Date: Tue, 23 Nov 1999 12:00:03 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: simple question for CGI and STDOUT
Message-Id: <slrn83l0ao.1kd.*@dragons.duesouth.net>

[Please, post once.
 Please, post under one subject only.
 Thanks]

On Sat, 20 Nov 1999 19:43:26 +0000, Dimitrios Kremmydas
<lzu99dk@rdg.ac.uk> spewed forth [and spewed forth, and spewed forth]: 
: if i close the STDOUT (close(STDOUT)), does the script kill itself ???
: if yes, how can i make the browser stop waiting for any more input from
: the script while the script will keep running ?

What happened when you tried it?

$ time perl -we 'close STDOUT; sleep 5'
0.01user 0.03system 0:05.05elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (255major+35minor)pagefaults 0swaps
$

The CGI protocol is not discussed in this group; for the second half of
your question, please ask in somewhere like comp.infosystems.www.authoring.cgi.  

: cheers

HTH,

--Matthew


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

Date: 23 Nov 1999 11:30:35 GMT
From: mgjv@localhost.localdomain (Martien Verbruggen)
Subject: Re: Simple question
Message-Id: <slrn83kup8.eau.mgjv@localhost.localdomain>

[Followups Set]

[your computer has a chronology problem. You answer arrived before the
text you were responding to. Please reverse your clock]
[you include too much text, next time, please use your delete key]

On Tue, 23 Nov 1999 03:11:33 -0500,
	Nico Zigouras <zigouras@mail.med.upenn.edu> wrote:
> On 23 Nov 1999, Kent Delcastillo wrote:
> > I'm writing a tiny script that'll route the user to a webpage based on a
> 
> print"Location: /yourpage.html\n\n";

Wrong.

Read RFCs 2068 and 1945 to find the following:

     Location       = "Location" ":" absoluteURI

notice the 'absolute' in there? They even have examples.

Now, please do not answer any more non-perl questions in a perl group.
Refer the poster to the correct group instead, or at least to a
hierarchy of groups like comp.infosystems.www.*.

Thank you,
Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | The gene pool could use a little
Commercial Dynamics Pty. Ltd.   | chlorine.
NSW, Australia                  | 


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

Date: Tue, 23 Nov 1999 13:17:02 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Simple question
Message-Id: <Pine.HPP.3.95a.991123130256.721E-100000@hpplus01.cern.ch>


(with respect, comp.lang.perl.misc added back temporarily, but f'up
retained).

On 23 Nov 1999, Martien Verbruggen wrote:

> > > I'm writing a tiny script that'll route the user to a webpage based on a
> > 
> > print"Location: /yourpage.html\n\n";
> 
> Wrong.

Maybe...

> Read RFCs 2068 and 1945 to find the following:
> 
>      Location       = "Location" ":" absoluteURI

But RFC2068 (now superseded by RFC2616) documents the HTTP protocol; but
what the script is returning is a CGI response.  CGI responses are
specified by the CGI/1.1 specification, originally at
hoohoo.ncsa.uiuc.edu, for which a draft RFC can now be found at
http://www.golux.com/~coar/cgi/

The relevant Perl FAQs, as I've said before, are rather unsatisfactory
in this regard, but _if_ they say anything, it ought to be correct.

> notice the 'absolute' in there? They even have examples.

http://www.golux.com/~coar/cgi/draft-coar-cgi-v11-03-clean.html#7.2.1.2

    Location         = "Location" ":"
                       ( fragment-URI | rel-URL-abs-path ) NL

Notice the rel-URL-abs-path option there?

This is a valid CGI Location: response.

However, the effect might or might not be what the questioner wanted.
The CGI spec explains it, and the questioner should read it and reach
their own conclusion.

> Now, please do not answer any more non-perl questions in a perl group.
> Refer the poster to the correct group instead, 

Good advice.  It would be comp.infosystems.www.authoring.cgi, but
cross-posting there isn't feasible due to the group's automoderation
policy.

best regards



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

Date: Tue, 23 Nov 1999 11:50:22 GMT
From: "Peter Lavender" <plaven@idl.net.au>
Subject: what is the equivilant in perl?
Message-Id: <01bf3589$80766e20$0909a8c0@winnie.sspl.net.au>

Hi everyone,

I'm having a few problems grasping the concepts of regular expressions and
how to get what I'm looking for, mostly from log files.

For example the following line get's the IP address for me from
/var/log/messages:

ISPIP=`cat /var/log/messages | grep 'local  IP address' | awk '{print $9 }'
| tail -n 1`

I can't get my mind around doing the same with a perl script and I think
it's all down to how to use regular expressions to do the above.

Thanks,

Pete


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

Date: Tue, 23 Nov 1999 11:55:37 GMT
From: "Douglas Garstang" <dgarstan@nsw.bigpond.net.au>
Subject: Re: what is the equivilant in perl?
Message-Id: <Zgv_3.4418$VA6.21259@news-server.bigpond.net.au>

Peter,

$var = qx(cat /var/log/messages | grep 'local  IP address' | awk '{print
$9 }' | tail -n 1` );
chomp($var);

 ...should do it for you! Haven't tested that....

You normally use regular expression operations on a single line at a time,
so you would still need to read the file in line-by-line if you wanted to
then do a regular expression test on it.

Regards
Douglas.

Peter Lavender wrote in message
<01bf3589$80766e20$0909a8c0@winnie.sspl.net.au>...
>Hi everyone,
>
>I'm having a few problems grasping the concepts of regular expressions and
>how to get what I'm looking for, mostly from log files.
>
>For example the following line get's the IP address for me from
>/var/log/messages:
>
>ISPIP=`cat /var/log/messages | grep 'local  IP address' | awk '{print $9 }'
>| tail -n 1`
>
>I can't get my mind around doing the same with a perl script and I think
>it's all down to how to use regular expressions to do the above.
>
>Thanks,
>
>Pete




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

Date: 23 Nov 1999 12:02:26 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: what is the equivilant in perl?
Message-Id: <slrn83l0ii.3i8.simon@othersideofthe.earth.li>

Douglas Garstang (comp.lang.perl.misc):
>$var = qx(cat /var/log/messages | grep 'local  IP address' | awk '{print
>$9 }' | tail -n 1` );
>chomp($var);
>
>...should do it for you! Haven't tested that....

There's a distinction between the letter of the question and the spirit
of the question that I think you're missing here. :)

While I'm in a good mood:

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

open MSGS, "/var/log/messages"
	or die "Simon says you should always check the retval of open() : $!";

# Look carefully here : We build a list of lines that match, then take
# the last one.
$_ = (grep {/local  IP address/} <MSGS>)[-1];

# I'm not sure about this...
print ((split)[8]);

-- 
Feel free to contact me (flames about my english and the useless of this
driver will be redirected to /dev/null, oh no, it's full...).
(Michael Beck, describing the PC-speaker sound device)


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

Date: Tue, 23 Nov 1999 12:30:02 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: what is the equivilant in perl?
Message-Id: <slrn83l1ei.1kd.*@dragons.duesouth.net>

Peter Lavender" <plaven@idl.net.au>, thinking with his hands, posted the
following to comp.lang.perl.misc: 
: ISPIP=`cat /var/log/messages | grep 'local  IP address' | awk '{print $9 }'
: | tail -n 1`

Useless use of cat.
 
: I can't get my mind around doing the same with a perl script and I think
: it's all down to how to use regular expressions to do the above.

Well, you _could_ use regular expressions, but there's no reason why you
_should_.

Long version:

    #!/usr/bin/perl -w
    my $file = shift or die "Usage: $0 <filename>\n";
    my $col;

    open FILE, $file or die "open($file): $!\n";
    
    while(<FILE>) {
        next if -1 == index $_, 'local  IP address';
    
        $col = (split " ")[8];
    }

    print "$col\n" if $col;
    __END__

Shorter version:

    #!/usr/bin/perl -wn
    next if -1 == index $_, 'local  IP address';
    $col = (split " ")[8]; END{print "$col\n" if $col};
    __END__

Shorter version:

    perl -lnwae '$col = $F[8] if -1 != index $_, "local  IP address"; END{print "$col" if $col}'

: Thanks,

Pick your poison,
 
: Pete

--Matthew


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

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 V9 Issue 1465
**************************************


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