[18675] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 843 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 6 18:07:37 2001

Date: Sun, 6 May 2001 15:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <989186706-v10-i843@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 6 May 2001     Volume: 10 Number: 843

Today's topics:
        cgi inter-process <alikbm@tx.technion.ac.il>
    Re: cgi inter-process (Michael P. Soulier)
    Re: flushing to gdbdm files (Garry Williams)
    Re: glob questions (Garry Williams)
    Re: Help on optimization wanted <michael@stroeck.com>
    Re: Help on optimization wanted <flavell@mail.cern.ch>
    Re: Help on optimization wanted (Craig Berry)
    Re: Help on optimization wanted <bart.lateur@skynet.be>
    Re: Help on optimization wanted <michael@stroeck.com>
    Re: Help on optimization wanted <michael@stroeck.com>
    Re: Help on optimization wanted <bjoern@hoehrmann.de>
    Re: Help on optimization wanted <bjoern@hoehrmann.de>
    Re: Help on optimization wanted <bart.lateur@skynet.be>
    Re: Help on optimization wanted <michael@stroeck.com>
    Re: Help on optimization wanted <bart.lateur@skynet.be>
    Re: Help on optimization wanted <bjoern@hoehrmann.de>
    Re: Help on optimization wanted (Abigail)
    Re: How to determine file type of a filehandle? <djmarcus@ex-pressnet.com>
    Re: leftover Close Wait sockets (Spork Boy)
    Re: Match/replace of HTML text without loss of tag info <jim1234@monetsgarden.net>
    Re: Passing references via recursion <temp133@hotmail.com>
        Perl & ODBC <jtjohnston@courrier.usherb.ca>
        sessions and closures (F. Xavier Noria)
        Simple Script Needed <chrishood@btinternet.com>
        Trying to fill in a Pager Web page. <ramseyk@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 6 May 2001 22:58:17 +0200
From: "alik blochin" <alikbm@tx.technion.ac.il>
Subject: cgi inter-process
Message-Id: <9d4a8o$stj$1@news.huji.ac.il>

Hi,
help is needed urgently..

the problem is :
  how can i start up a process within some perl/CGI
 script and to make the page load instantly without
 waiting the end of the started process.
# the process can take some time to complete and
  the browser gets timed out;

when i run the script from command line everything
 is ok, the process started and i exit the script;
but in browser the script waiting for process end....

initially i use :

print <<HEADER;
 ...
 ...
 ...
HEADER

  if ($pid=fork)
    /.. something /
  else
   if defined($pid) {
    exec("process")
  }

print <<TAIL;
 ....the process pid is : $pid<br>
 ....
 ....
</body></html>
TAIL


what's wrong with that ?
or maybe this is a wrong aproach ?




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

Date: Sun, 06 May 2001 20:27:21 GMT
From: msoulier@storm.ca (Michael P. Soulier)
Subject: Re: cgi inter-process
Message-Id: <JsiJ6.83041$HF.17864364@news4.rdc1.on.home.com>

On Sun, 6 May 2001 22:58:17 +0200, alik blochin <alikbm@tx.technion.ac.il>
wrote:
> 
> when i run the script from command line everything
>  is ok, the process started and i exit the script;
> but in browser the script waiting for process end....
> 
> initially i use :
> 
> print <<HEADER;
> ...
> ...
> ...
> HEADER
> 
>   if ($pid=fork)
>     /.. something /
>   else
>    if defined($pid) {
>     exec("process")
>   }

    It might help if you use Perl code, which the above is most certainly not.

    When you fork, the file descriptors for stdout, stdin and stderr are
duplicated. The browser is waiting for stdout to be closed, but your forked
child still has it open. Try this.

    if ($pid = fork) {
        # We are the parent
    }
    else {
        close STDOUT;
        close STDERR;
        exec "process";
    }

    Mike

-- 
Michael P. Soulier <msoulier@storm.ca> 
"With sufficient thrust, pigs fly just fine. However, this is not necessarily a
good idea. It is hard to be sure where they are going to land, and it could be
dangerous sitting under them as they fly overhead." -- RFC 1925


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

Date: Sun, 06 May 2001 17:32:25 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: flushing to gdbdm files
Message-Id: <slrn9fb2l9.11r.garry@zfw.zvolve.net>

On 3 May 2001 09:44:45 GMT, Diana McCarthy <dianam@cogs.susx.ac.uk> wrote:
> I wish to flush buffers at specific points in my program. I can see that
> $oldfh = select("FILE");
> $| = 1;
> 
> will flush FILE automatically, (presumably until I change back with $| = 0).
> Can I flush to GBDM files

Maybe this is a reason to use DB_File instead.  It's manual page
documents the sync() method on a tie'd hash.  

I don't have GDBM_File installed, so I don't know if it offers similar
functionality.  

-- 
Garry Williams


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

Date: Sun, 06 May 2001 17:41:19 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: glob questions
Message-Id: <slrn9fb35v.11r.garry@zfw.zvolve.net>

On Tue, 01 May 2001 12:38:09 GMT, Rob <> wrote:

> QUESTION TWO
> Why does glob (path\*) return to me a list of all directories and
> files in the directory *except* for . and ..?

It doesn't.  

It skips over *all* names begining with `.'.  To get files beginning
with a `.', use something like "path/.*".  

-- 
Garry Williams


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

Date: Sun, 6 May 2001 18:11:11 +0200
From: "Michael Ströck" <michael@stroeck.com>
Subject: Re: Help on optimization wanted
Message-Id: <3af5777e@e-post.inode.at>

"Abigail" <abigail@foad.org> schrieb im Newsbeitrag
news:slrn9fafrr.der.abigail@tsathoggua.rlyeh.net...

> There's no much pointing out micro optimizations if you are better
> off scratching the entire program and implement a much better algorithm.
> One based on sieves, for instance. If you are doing a CS program, you
> should have math as well, and I would be surprised if sieves aren't
> discussed there.
> Abigail

Thanks. But ... :-))

I'm talking about high-school-level education here. I'm 17 years old
and currently attending a "Gymnasium" in Austria. That's like an american
high-school, only that I'll be able to read when I graduate later this year
;-)
I said "CS" because I could think of no better translation for the name
of this particular subject.

In my post I said that I'm new to Perl, so my request was more in terms
of pointing out mistakes in loop-logic.

So I have no idea what sieves are :-) But if you could point me to some
information ?


Michael Ströck




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

Date: Sun, 6 May 2001 18:38:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help on optimization wanted
Message-Id: <Pine.LNX.4.30.0105061825080.16484-100000@lxplus003.cern.ch>

On Sun, 6 May 2001, Michael Ströck wrote:

> So I have no idea what sieves are :-) But if you could point me to some
> information ?

That's an algorithms question, not a Perl language question as such;
but see http://www.math.utah.edu/history/eratosthenes.html
or do a web search for the name.

Re. Perl language techniques, it unsettles me when I see an outer loop
being controlled (iterated or exit-ed) based on something happening
within an inner loop, by referencing the name (label) of the outer
loop.  Maybe my misgivings are unjustified, based on superstitions
about GOTO, or something; but I'd rather see the inner loop being a
logical function returning true or false, and the outer loop testing
that to see whether execution should continue or iterate, than to see
things like "next OUTER" in an inner block.

The regulars will probably tell me I'm raving, though...  (perhaps I'm
just being nostalgic for BCPL...).

all the best



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

Date: Sun, 06 May 2001 18:24:45 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help on optimization wanted
Message-Id: <tfb5nd19910l1d@corp.supernews.com>

Michael Ströck (michael@stroeck.com) wrote:
: So I have no idea what sieves are :-) But if you could point me to some
: information ?

Basically, the idea is to eliminate all the not-primes from a list of
numbers, so what's left is the primes you want.

Probably easiest to show an example:


#!/usr/bin/perl -w
# sieve - find primes using a sieve
# Craig Berry (20010506)

use strict;

my $max   = shift || 100;
my $limit = int sqrt($max);
my @sieve = (0, 0, (1) x ($max - 1));

for (my $n = 2; $n <= $limit; $n++) {
  if ($sieve[$n]) {
    for (my $i = 2 * $n; $i <= $max; $i += $n) {
      $sieve[$i] = 0;
    }
  }
}

for (my $n = 2; $n <= $max; $n++) {
  print "$n is prime\n" if $sieve[$n];
}


-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Sun, 06 May 2001 20:13:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help on optimization wanted
Message-Id: <n4cbftcddun7h1cja2dcqq0e10ag4psen2@4ax.com>

Gwyn Judd wrote:

>     PRIME:
>>    foreach (@primes) {
>>        next LOOP if ($current_number % $_ == 0);
>         last PRIME if $_ ** 2 >= $current_number;
>>    }

I would expect

	$_ * $_ 

to be faster than

	$_ ** 2

-- 
	Bart.


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

Date: Sun, 6 May 2001 22:44:18 +0200
From: "Michael Ströck" <michael@stroeck.com>
Subject: Re: Help on optimization wanted
Message-Id: <3af5b781@e-post.inode.at>

> That's an algorithms question, not a Perl language question as such;
> but see http://www.math.utah.edu/history/eratosthenes.html
> or do a web search for the name.

Thanks, I'll have a look at it.

> Re. Perl language techniques, it unsettles me when I see an outer loop
> being controlled (iterated or exit-ed) based on something happening
> within an inner loop, by referencing the name (label) of the outer
> loop.  Maybe my misgivings are unjustified, based on superstitions
> about GOTO, or something; but I'd rather see the inner loop being a
> logical function returning true or false, and the outer loop testing
> that to see whether execution should continue or iterate, than to see
> things like "next OUTER" in an inner block.

I just knew that would pop up :-) I agree with you on the whole, but
sometimes I think that a GOTO is just much more logical and easy to
follow than more elobarate loop logic.

In my example, I think it's  more natural to say "if you find a modulus 0,
forget the current number and get a new one." Especially in such a basic
script.


Michael Ströck




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

Date: Sun, 6 May 2001 22:53:23 +0200
From: "Michael Ströck" <michael@stroeck.com>
Subject: Re: Help on optimization wanted
Message-Id: <3af5b9a1$1@e-post.inode.at>

Thanks a lot Craig. That's several orders of magnitude
faster than my script.

I don't really understand the following however:
> my @sieve = (0, 0, (1) x ($max - 1));
                                       ^
Could you (somebody) explain that syntax ? Especially
the "x" and the 1 in parens.


Michael Ströck




"Craig Berry" <cberry@cinenet.net> schrieb im Newsbeitrag
news:tfb5nd19910l1d@corp.supernews.com...
> Michael Ströck (michael@stroeck.com) wrote:
> : So I have no idea what sieves are :-) But if you could point me to some
> : information ?
>
> Basically, the idea is to eliminate all the not-primes from a list of
> numbers, so what's left is the primes you want.
>
> Probably easiest to show an example:
>
>
> #!/usr/bin/perl -w
> # sieve - find primes using a sieve
> # Craig Berry (20010506)
>
> use strict;
>
> my $max   = shift || 100;
> my $limit = int sqrt($max);
> my @sieve = (0, 0, (1) x ($max - 1));
>
> for (my $n = 2; $n <= $limit; $n++) {
>   if ($sieve[$n]) {
>     for (my $i = 2 * $n; $i <= $max; $i += $n) {
>       $sieve[$i] = 0;
>     }
>   }
> }
>
> for (my $n = 2; $n <= $max; $n++) {
>   print "$n is prime\n" if $sieve[$n];
> }
>
>
> --
>    |   Craig Berry - http://www.cinenet.net/~cberry/
>  --*--  "God becomes as we are that we may be as he is."
>    |               - William Blake




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

Date: Sun, 06 May 2001 23:09:19 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Help on optimization wanted
Message-Id: <3b07b99d.35713913@news.bjoern.hoehrmann.de>

* Michael Ströck wrote in comp.lang.perl.misc:
>One of our CS teachers at school told me to write a
>script that finds all primes from 1 - n.
>
>Writing that script was easy, but as I'm very new to
>Perl, I'd really appreciate any comments on how to
>make the following script run faster.

We had a longer Thread on this in de.comp.lang.perl.misc, see
<8pfjqi$8qm$12$1@news.t-online.com> ff. we came to

sub a{
 for (my $wert=2;$wert<10000;$wert++) {
  my $prim= 1;
  for (my $a=2;$a<$wert;$a++) {
   if ($wert % $a == 0) {
    $prim= 0;
    last;
   }
  }
 }
}
sub b{
 for (my $wert=2;$wert<10000;$wert++){
  my $ergebnis = 1;
  for (my $a=2;$a<$wert;$a++) {
   last if $a*$a > $wert;
   if ($wert % $a == 0) {
    $ergebnis = 0;
    last;
   }
  }
 }
}
sub c {
 my @prim = (2);
 for (my $test = 3; $test < 10000; $test+=2) {
  my $prim = 1;
  foreach (@prim) {
   unless ($test % $_) {
    $prim = 0;
    last;
   }
  }
  push @prim, $test if $prim;
 }
}                                   
sub d {
 my @prim = (2);
 for (my $test = 3; $test < 10000; $test+=2) {
  my $prim= 1;
  foreach (@prim) {
   last if $_*$_ > $test;
   unless ($test % $_) {
    $prim= 0;
    last;
   }
  }
   push @prim, $test if $prim;
 }
}
sub e {
 my @prim;
 for (my $n= 3; $n< 10000; $n+=2) {
  for ($i=2; $i<sqrt($n) && $n%$i; $i++){}
   push @prim, $n if $n%$i;
 }
}                      

sub f {
 my @prim;
  for (my $n= 3; $n< 10000; $n+=2) {
   for ($i=3; $i<sqrt($n) && $n%$i; $i+=2){}
    push @prim, $n if $n%$i;
  }                                            
}

Benchmark: timing 50 iterations of b, c, d, e, f...
         b: 18 wallclock secs (18.02 usr +  0.00 sys = 18.02 CPU)
         c: 62 wallclock secs (62.06 usr +  0.00 sys = 62.06 CPU)
         d:  6 wallclock secs ( 6.13 usr +  0.00 sys =  6.13 CPU)
         e: 13 wallclock secs (13.08 usr +  0.00 sys = 13.08 CPU)
         f:  7 wallclock secs ( 7.44 usr +  0.00 sys =  7.44 CPU)     

Where c) and d) where my subs. Just for some inspirations...
-- 
Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/


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

Date: Sun, 06 May 2001 23:15:37 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Help on optimization wanted
Message-Id: <3b08bde8.36812763@news.bjoern.hoehrmann.de>

* Michael Ströck wrote in comp.lang.perl.misc:
>I don't really understand the following however:
>> my @sieve = (0, 0, (1) x ($max - 1));
>                                       ^
>Could you (somebody) explain that syntax ? Especially
>the "x" and the 1 in parens.

See `perldoc perlop`/"Multiplicative Operators" for the 'x' (repetition
operator). Parens create lists in Perl

  my @list = (1);

creates a list with '1' as the first element,

  my @list = (1) x 10;

creates a list with '1' as the first, second ... 10th element.
-- 
Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/


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

Date: Sun, 06 May 2001 21:15:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help on optimization wanted
Message-Id: <5pfbftkfspqjk8kjgr4ju2t75qv60fil21@4ax.com>

Bjoern Hoehrmann wrote:

>Benchmark: timing 50 iterations of b, c, d, e, f...

What happened to a?

-- 
	Bart.


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

Date: Sun, 6 May 2001 23:21:18 +0200
From: "Michael Ströck" <michael@stroeck.com>
Subject: Re: Help on optimization wanted
Message-Id: <3af5c02c@e-post.inode.at>

Thanks, what I didn't understand was why the "1" had to be
in parens.


Michael Ströck

"Bjoern Hoehrmann" <bjoern@hoehrmann.de> schrieb im Newsbeitrag
news:3b08bde8.36812763@news.bjoern.hoehrmann.de...
> * Michael Ströck wrote in comp.lang.perl.misc:
> >I don't really understand the following however:
> >> my @sieve = (0, 0, (1) x ($max - 1));
> >                                       ^
> >Could you (somebody) explain that syntax ? Especially
> >the "x" and the 1 in parens.
>
> See `perldoc perlop`/"Multiplicative Operators" for the 'x' (repetition
> operator). Parens create lists in Perl
>
>   my @list = (1);
>
> creates a list with '1' as the first element,
>
>   my @list = (1) x 10;
>
> creates a list with '1' as the first, second ... 10th element.
> --
> Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
> am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
> 25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/




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

Date: Sun, 06 May 2001 21:40:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help on optimization wanted
Message-Id: <73hbfts5jrk59bbcn9i9f1mk3rqls6k47f@4ax.com>

Michael Ströck wrote:

>Thanks, what I didn't understand was why the "1" had to be
>in parens.

Because that makes a list of  1's, not a string like "11111".

	@a = (1) x 5;
	print join '-', @a; print "\n";

	@a = 1 x 5;
	print join '-', @a; print "\n";
-->
	1-1-1-1-1
	11111

The latter piece of  code, although very similar to the former, returns
1 string of five times "1". The former returns a list of five strings
"1".

-- 
	Bart.


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

Date: Sun, 06 May 2001 23:47:40 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Help on optimization wanted
Message-Id: <3b0fc58a.38766363@news.bjoern.hoehrmann.de>

* Bart Lateur wrote in comp.lang.perl.misc:
>Bjoern Hoehrmann wrote:
>
>>Benchmark: timing 50 iterations of b, c, d, e, f...
>
>What happened to a?

Good question... Hm, ok, a() was damn slow (benchmark for 3..1_000):

Benchmark: timing 500 iterations of a, b, c, d, e...
         a: 80 wallclock secs (79.20 usr +  0.00 sys = 79.20 CPU)
         b:  9 wallclock secs ( 9.31 usr +  0.00 sys =  9.31 CPU)
         c: 13 wallclock secs (13.57 usr +  0.00 sys = 13.57 CPU)
         d:  5 wallclock secs ( 4.47 usr +  0.00 sys =  4.47 CPU)
         e:  6 wallclock secs ( 6.32 usr +  0.00 sys =  6.32 CPU) 

(yes, here is f() missing, I'm just quoting the results from
<8pgt0u$csnku$8@ID-24002.news.cis.dfn.de>) I think Tina (who did the
benchmarks) got rid of it in <8ph4si$csnku$15@ID-24002.news.cis.dfn.de>.
-- 
Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/


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

Date: Sun, 6 May 2001 21:55:21 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Help on optimization wanted
Message-Id: <slrn9fbi29.ti0.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCCCV September MCMXCIII
in <URL:news:n4cbftcddun7h1cja2dcqq0e10ag4psen2@4ax.com>:
[]  Gwyn Judd wrote:
[]  
[] >     PRIME:
[] >>    foreach (@primes) {
[] >>        next LOOP if ($current_number % $_ == 0);
[] >         last PRIME if $_ ** 2 >= $current_number;
[] >>    }
[]  
[]  I would expect
[]  
[]  	$_ * $_ 
[]  
[]  to be faster than
[]  
[]  	$_ ** 2


I would expect a compiler to be smart enough to know both expressions
are equivalent, and to do whatever is the fastest on the platform it
runs on.


Abigail


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

Date: Sun, 6 May 2001 11:32:52 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: How to determine file type of a filehandle?
Message-Id: <tfarkfdkc540d0@corp.supernews.com>

I encounter the following on AS 5.6.1 on W2Kpro (the same problem exists on
AS 5.6.0).

        $sock = IO:Socket::INET->new( Proto => 'tcp', PeerAddr =>
'...hostname...', PeerPort => $port);

the connection succeeds (as I can show by read/write to the socket).

I tried the following code to display what the $sock is encapsulating:

print "File type of \$sock = ", FileType($sock), "\n";
print "File type of fileno(\$sock) = ", FileType(fileno($sock)), "\n";

# I tried both versions since the very sparse documentation on the 'if -r'
and others does not mention whether they want a glob, a file handle or a
fileno integer.

sub FileType
{   my ($fh) = @_;
    my $type = "";
    $type .= " Readable" if -r $fh;
    $type .= " Socket" if -S $fh;
    $type .= " Interactive" if -t $fh;
    $type .= " BlkDev" if -b $fh;
    $type .= " CharDev" if -c $fh;

    return $type;
}

On W2Kpro:
    both print statements the call to FileType() generated the empty string.
This means that none of the conditionals were true.

On W'98:
    the value returned by FileType was ' Interactive'.

In neither case was the handle recognized as a socket.

I am wondering is this a bug in AS 5.6.* or is this a general perl problem.

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

The need spurring this posting is to be able to
    1) listen for incoming connections
    2) accept a connection
    3) fire off a new process  to handle the specific communications with
the client
        3a) Redirect STDIN to accepted socket
        3b) Win32::Process::Create() a new process, using file handle
inheritance to pass the socket via STDIN.
               I am very careful with the parameters:
                    $rc = Win32::Process:Create( $process,

$program,          #set to: 'c:\perl\bin\perl.exe'

$cmdline,           #set to: 'c:\mydir\myprog.pl'

$inherit,              #set to: 1

$flags,                #set to: 0 (means run without a console)

$dir);                  #set to: '.'

    4) close the accepted socket and listen for more connections

    the new process
    1) create a socket: my $sock = IO::Socket::INET->new_from_fd(
fileno($STDIN), "+<");
    2) read/write from the socket

By the way, this approach is described in Dave Roth's book on Win32 Perl
Scripting (examples 7.22 & 7.23).

This approach is mandated because the fork() on AS 5.6.* under windows is
emulated insufficiently for my needs.

The redirection of STDIN seems to work (no errors reported).
The process creation works (since the program kicked off writes to a file
and I see the output).

The problem I am seeing is the read/write in the new process fails with a
'bad file handle' message. Somehow the socket did not get passed

I find that this does not work no matter how I try.

I tried to display what perl thinks is behind the socket, but as mentioned
above, it does not display anything.

Any concrete ideas would be greatly appreciated.

If I can't get this resolved, I will have to consider paying AS their $195
fee for resolving an incident or drop perl altogether from the solution
(I've already spent over a week of time fruitless from a results point of
view but at least productive in learning the quirks of perl) which would be
a shame since it is such a good fit.

-TIA
David



"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:9l9aft8csgn86dc7gr4mnl88r58km5h5tv@4ax.com...
> David J. Marcus wrote:
>
> >Given a file handle, $fh, how can I determine what kind of file the
handle
> >is associated with. In particular, the $fh can come from a socket, a disk
> >file, console, etc.
> >
> >The environment is AS Perl 5.6.1, running on W'98 and W2K.
>
> open the docs for perlfunc, and search for "-X". In particular, check
> out -t, -S, -p and -f.
>
> --
> Bart.




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

Date: Sun, 06 May 2001 17:47:33 GMT
From: sporkboy@Spork.na (Spork Boy)
Subject: Re: leftover Close Wait sockets
Message-Id: <slrn9fb3hj.47n.sporkboy@Spork.na>

In article <9d2kgj$fu3df$1@ID-13368.news.dfncis.de>, Samuel Kilchenmann wrote:
> "Spork Boy" <sporkboy@Spork.na> wrote in:
> news:slrn9f91mq.u4i.sporkboy@Spork.na...
>> In article <9d19ct$g2uva$1@ID-13368.news.dfncis.de>, Samuel
> Kilchenmann wrote:
>> >
>> > shutdown(SOCKET, 1) || die "shutdown write: $!";
>> > while (<SOCKET> {
>> >   print;
>> > }
>> > shutdown(SOCKET, 0) || die "shutdown read: $!";
>>
>> It says there's an error near }
>>
> 
> Sorry for the typo, the line
> while (<SOCKET> {
> should be
> while (<SOCKET>) {
> 
> Ok, lets give it a last try. What happens if you run the following
> script (with your WinampRC hostname and port as parameters) and enter
> "quit" after the connection has been established? Is the final output
> "remote closed connection"? If not, then WinampRC is buggy. If yes,
> but the socket on the Winamp machine remains in CLOSE_WAIT state, then
> either your Linux or Windows TCP/IP implementation or WinampRC has a
> problem. But since you seem to get the same results from either Perl
> or telnet, its most likely not a Perl problem.
> 
<snip>

it says "asked remote to close connection", the socket on the win side goes
close wait, and the script just sits there. So I'm guessing that means
there's really no way around it. Well, thanks for all the help.

-- 
+---------------+
|     Spork Boy | Deep Thought:
| AIM: Sporkite | A week before Lincoln was shot, he was in Monroe, Maryland.
|   ICQ: 859886 | A week before Kennedy was shot, he was in Marilyn Monroe.
+---------------+


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

Date: Sun, 06 May 2001 20:15:31 GMT
From: Jim Schaerer <jim1234@monetsgarden.net>
Subject: Re: Match/replace of HTML text without loss of tag information
Message-Id: <qgabftsscsireki427usmburkedm28kooh@4ax.com>

James,

Thank you very much for your help, in spite of the fact that I asked
such a common question.  I would like to apologize; I should have done
a better job of researching my problem before I posted.  For the
record, I did make an honest attempt to find an answer, though my
search was completely misdirected by my lack of knowledge on what
exactly I was looking for.  I will now explore my problem from the
appropriate (module-based) angle, and hope to find a solution there
that will fit my needs.

- Jim

P.S. - Another thanks for your explanation of regexs, even though my
attempt to use them was erroneous.

On Sun, 06 May 2001 21:26:39 +1000, James Freeman
<jfreeman@tassie.net.au> wrote:

>Jim Schaerer wrote:
>
>> Hello, all.
>>
>> I'm attempting to write a Perl regular expression match/replace
>> statement to change text in a HTML document without compromising the
>> information in the HTML tags themselves.
>
>Short answer look at some of the modules that do this knd of thing.
>HTML::TokeParser is a good start. Also this type of request is common so
>check out the usenet archive for answers. If you want to know why your
>regexes do what they do read on.

(snip)


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

Date: Sun, 6 May 2001 10:28:19 -0700
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Re: Passing references via recursion
Message-Id: <9d41jp$h6j$1@agate.berkeley.edu>

Hmmm, interesting. It seems to work now. I printed out your
code and used it to modify my own and it works perfectly.
Strange thing is, I can't really see any difference between
what you did and what I originally posted (except for passing
$root. In my code $root is actually a global).

As for Mr. Kilchenmann's code, I don't know what in-out
parameters are. Are they subroutines which modify their
parameters rather than returning new values? If so, I agree.
The problem with your code though, is that it customizes
recurse to do a specific thing: append lines. I have too many
instance in older code of subroutines like recurse1, recurse2,
recurse3, and such. I never want to have to do that again.

Of course what I'd REALLY like to do is make the tree into
an object with its own iterator but I've never been able to make
that work in perl. Oh well, baby steps.

Thank you VERY much, both of you, for the time you've
taken to help me out, and the thought you obviously put
into analyzing my code.

Arvin


Joe Schaefer <joe+usenet@sunstarsys.com> wrote in message
news:m3bsp72kzd.fsf@mumonkan.sunstarsys.com...
> "Arvin Portlock" <temp133@hotmail.com> writes:
>
> > I'm using recursion on a tree to append data to a variable.
> > I want to try and do it without using global variables. I can't
> > seem to do it.
>
> Did you enable warnings and strictures then?
>
> > Here's what I have tried (among various other things):
> >
> > sub print_locations {
> >    my $locations;
> >    recurse ($root, \&append_location, \$locations);
>               ^^^^^
>
> This variable appears from out of the blue- why not pass it as
> an argument?
>
> [...rest looks ok to me...]
>
> #!/usr/bin/perl -w
> use strict;
>
> sub print_locations {
>    my $locations;
>    recurse (shift, \&append_location, \$locations);
>    print $locations;
> }
> sub recurse {
>    my ($node, $subref, $param) = @_;
>    if ($node) {
>       $subref->($node, $param);
>       recurse ($node->{sub}, $subref, $param);
>       recurse ($node->{next}, $subref, $param);
>    }
> }
>
> sub append_location {
>    my ($node, $locations) = @_;
>    $$locations .= $node->{place};
> }
>
> my $root = {
>    place => "first",
>              sub => {
>                       place => "second",
>                         sub => undef,
>                        next => {
>         place => "third",
>                                   sub => undef,
>          next => undef,
>        },
>     },
>     next => {
>         place => "fourth",
>                         sub => {
>         place => "fifth",
>                                   sub => undef,
>          next => undef,
>        },
>        next => undef,
>     },
>
>    };
>
> print_locations($root);
> __END__
>
> output:
> firstsecondthirdfourthfifth
>
> --
> Joe Schaefer            "Familiarity breeds contempt -- and children."
>                                                --Mark Twain




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

Date: Sun, 06 May 2001 17:20:27 -0400
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Perl & ODBC
Message-Id: <3AF5C01B.35C3C11D@courrier.usherb.ca>

Can I use and access Microsoft Access *.mdb files without having a sql
server?
For example, I was consulting this:
    http://www.geocities.com/Area51/Cavern/4503/perl_odbc.htm
But it talks about a SQL server acting as an intermediary. I'm sure I've
seen this done without a SQL server?

(My ISP won't give me access to a SQL server; nor do I want one. I
normally database with *.text files, but want a new challenge.)

John
(P.S. an email post and reply would eb appreciated.)



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

Date: Sun, 06 May 2001 21:49:30 GMT
From: fxn@isoco.com (F. Xavier Noria)
Subject: sessions and closures
Message-Id: <3af5c395.1143004@news.iddeo.es>

Paul Graham explained in a recent talk  that in Yahoo Stores
the sessions are maintained using closures:

   One of the problems with using Web pages as a UI is the
   inherent statelessness of Web sessions.  We got around
   this by using lexical closures to simulate subroutine-like
   behavior.  If you understand about continuations, one way
   to explain what we did would be to say that we wrote our
   software in continuation-passing style. [...]

Sounds elegant! Have any of you tried this approach with Perl?
Could you please comment a bit on this?

-- fxn

[*] http://www.paulgraham.com/lwba.html


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

Date: Sun, 6 May 2001 22:27:05 +0100
From: "Cut Throat" <chrishood@btinternet.com>
Subject: Simple Script Needed
Message-Id: <9d4fiq$g09$1@newsg3.svr.pol.co.uk>

Lo everyone,
Hopefully you bright people here can help me out,
Either by giving me a link to a tute,
Telling me where to look and what to look for,
Or writing a script for me,

Anyway > i have posted here because I know what I want but i dont know what
topic it come under,
Below is all as an example > i have written it like it is because it is alot
easier to understand what way,

Say I have 2 pages,
On EACH of those pages i a line of text,
For example :  Page 1 has :  Hello and welcome to the old page,
And page 2 had : Hello and welcome to the new page.

Every day I have to change those pages > by changing the line of text on
them,
Now at the moment I am having to modify them manually,
What I need to do is relate the lines of text on each page to a single text
file,
So page 1s line of text will read it off line 1 of the single text file,
And page 2s line of text (which is different) will read it off line 2 of the
single text file,.

So what i would have now in this example > is 2 blank pages with something
like a script on it pointing to a text file or script, ANd a text file or
script saying :

Hello and welcome to the old page,
Hello and welcome to the new page,

Then say I wanted to change page one to say Hello and welcome to the NEW
page and page 2 saying Hello and welcome to the OLD page. Then all I would
need to do is open the one single text or script file and just change the
lines,

NOw that was a simple example because as you can tell it is hard to explain,
The only adaptions I would make is that it is about 14 pages i need to
change,

Now how would i do this?

ANY HELP AT ALL WILL HELP ! ! :0)

Thanks everyone for reading this,
Chris

http://ci5.10-4.net
ICQ : 60091213




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

Date: Sun, 06 May 2001 20:20:37 GMT
From: Kathy Ramsey <ramseyk@home.com>
Subject: Trying to fill in a Pager Web page.
Message-Id: <3AF5B214.12231392@home.com>

I am trying to feed a pager # and message to www.arch.com - a pager web
site.
where do I begin!

newbie
Kathy



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

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


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