[7058] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 683 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 29 22:17:17 1997

Date: Sun, 29 Jun 97 19:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 29 Jun 1997     Volume: 8 Number: 683

Today's topics:
     [Q]: Passing arrays by reference to prototyped function <dwc3q@mamba.cs.Virginia.EDU>
     Re: CGI.PM or cgi-lib.pl? and strange errors? <rootbeer@teleport.com>
     Re: changing environmental variables (Nathan Neulinger)
     Re: could this script be made more optimized?? (Nathan Neulinger)
     Re: Getting Perl 5.00401 to compile on SCO 3.2.4 (Ed Wilborne)
     Re: lastIndexOf ( String, SubStringRegex ) <mehta@mama.indstate.edu>
     Re: lastIndexOf ( String, SubStringRegex ) <rootbeer@teleport.com>
     Re: Learning Perl <rootbeer@teleport.com>
     Re: Learning Perl <rootbeer@teleport.com>
     Re: Learning Perl <rootbeer@teleport.com>
     LWP:Simple anon ftp problem (David Faciane)
     Re: LWP:Simple anon ftp problem <aas@bergen.sn.no>
     Re: Perl 5.004_01 is available (binary for DOS, Win* an (Ilya Zakharevich)
     Re: Perl and killing processes <rootbeer@teleport.com>
     Re: Problems with HTTP_REFERER <rootbeer@teleport.com>
     Programming more, sleeping less. How do you stay awake? (Craig Brown)
     Test Drive 1500 of the Best Software Titles (Ed Tsigal)
     Update Access or Foxpro Database (Harold J. Fennell)
     using Perl's "open" on devices (Peter Daum)
     Re: Variable help please (Andrew M. Langmead)
     Re: Zombie processes under system load <rootbeer@teleport.com>
     Re: Zombie processes under system load <wayne@cta-challenge.com.au>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 29 Jun 1997 18:59:35 GMT
From: "David W. Coppit" <dwc3q@mamba.cs.Virginia.EDU>
Subject: [Q]: Passing arrays by reference to prototyped functions
Message-Id: <Pine.SOL.3.96.970629145439.19710A-100000@mamba.cs.Virginia.EDU>


I get the message "Bizarre copy of ARRAY in aassign" when I try to do the
following:

sub foo(\@$@) {
  my @copy = @{(shift)};
  my $scalarvar = shift;
  my @optional = @_;

 ...
}

foo (@array1,0,@array2);

I'm trying to make the third argument optional. If I change it to a
reference and treat it like the first argument, everything is okay, but it
seems to me that this shouldn't be necessary. Am I missing something?

Thanks,
David

_________________________________________________________________________
David Coppit - Graduate Student        coppit@cs.virginia.edu
The University of Virginia             http://www.cs.virginia.edu/~dwc3q
"Never imagine yourself not to be otherwise than what it might appear to
others that what you were or might have been was not otherwise than what
you had been would have appeared to them to be otherwise." -Lewis Carroll



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

Date: Sun, 29 Jun 1997 11:35:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: perl perl perl <guitarweb@hotmail.com>
Subject: Re: CGI.PM or cgi-lib.pl? and strange errors?
Message-Id: <Pine.GSO.3.96.970629112814.29224K-100000@kelly.teleport.com>

On Sun, 29 Jun 1997, perl perl perl wrote:

> i know i need to read up on this, 

Are you saying that you know that somebody has already written what you
want to read, but you want us to write it here so you can read this
instead? :-)

> but i have a program running now people are using. i only want to know
> (as i've heard), that cgi.pm is far better then using the cgi-lib.pl?

If you're asking if you've heard that CGI.pm is better than cgi-lib.pl,
then yes, I think you have heard that. Would you like to hear it again?
:-)

> if so, does anything need to be changed in my script or otherwise?

Besides what's listed in the CGI.pm docs? Not much...

As for the error messages that you listed, check perldiag(1) for the perl
messages. For others, see whether they're listed in the docs for your
server or other utilities you use. If you can't find them anywhere, the
strings command may be able to help. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 29 Jun 1997 17:42:19 -0500
From: nneul@umr.edu (Nathan Neulinger)
Subject: Re: changing environmental variables
Message-Id: <nneul-2906971742200001@dialup-pkr-10-16.network.umr.edu>

In article <33B2DE42.549@SanDiegoCA.NCR.COM>, Ray Mitchell
<Ray.Mitchell@SanDiegoCA.NCR.COM> wrote:

| Hi all,
|         I'm running Perl 5 under WinNT 4.0.  Is there any way to change the
| environmental variables and have the changes remain after the perl
| script finishes executing?  I've tried changing and adding new key/value
| pairs to the %ENV hash, using backtics - `set VAR=VALUE`, and using the
| system and exec functions - system "set VAR=VALUE".  None of these
| works.  I've also tried this on a UNIX system, and it does not work
| there either.

Don't know about NT, but on UNIX, environment variables are inherited from
the parent process. Each new process gets it's own copy of the varibles.
The only thing you could do is pass it on to a new process or eval the
output of the perl script.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                  Univ. of Missouri - Rolla
EMail: nneul@umr.edu                  Computing Services
WWW: http://www.umr.edu/~nneul      SysAdmin: rollanet.org


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

Date: Sun, 29 Jun 1997 17:53:12 -0500
From: nneul@umr.edu (Nathan Neulinger)
Subject: Re: could this script be made more optimized??
Message-Id: <nneul-2906971753120001@dialup-pkr-10-16.network.umr.edu>

| while($line=<OUTPUT>){
|         if ($line =~/<!--begin-->/){
|                 print OUTPUT $lake{'comments'}, "<br>\n";}
| }

You can. From the perl 4 man page, right in the beginning: (I'm not sure
where in perl5 docs it is)

| |                 #!/usr/bin/perl
| |                 while (<>) {
| |                      if ($ARGV ne $oldargv) {
| |                           rename($ARGV, $ARGV . '.bak');
| |                           open(ARGVOUT, ">$ARGV");
| |                           select(ARGVOUT);
| |                           $oldargv = $ARGV;
| |                      }
| |                      s/foo/bar/;
| |                 }
| |                 continue {
| |                     print;     # this prints to original filename
| |                 }
| |                 select(STDOUT);

That's from the example about "perl -pi".

You should be able to modify that to suit your needs.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                  Univ. of Missouri - Rolla
EMail: nneul@umr.edu                  Computing Services
WWW: http://www.umr.edu/~nneul      SysAdmin: rollanet.org


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

Date: Mon, 30 Jun 1997 00:07:53 GMT
From: NOstargazer@gamewood.net (Ed Wilborne)
Subject: Re: Getting Perl 5.00401 to compile on SCO 3.2.4
Message-Id: <33b6f825.383280@news.gamewood.net>

I've partially answered my own question.  The problem I was having was
when the linker started to link in libcrypt.a.  It would complain
about the files being linked were in COFF and OMF format.  Knowing
nothing about which format which was in or how to check, I simply
started using trial and error to resolve the problem.  Seem to have
got it on the first try too.  I replaced /usr/lib/libcrypt.a
references in config.sh with /usr/lib/libcrypt_d.a and started the
make process over by running:

sh Configure -S
make depend
make
make test
make install

Good luck, if you have SCO...  It works, although the test procedure
complained the "cpp" function/feature didn't work, that was the only
problem!

NOstargazer@gamewood.net (Ed Wilborne) wrote:

>I'm having a hard time using the Configure script to get Perl 5
>compiled on SCO V 3.2.4.  Can anybody recommend a place to look for
>installation help with this release, or make other recommendations if
>you have it up and running successfully?
>
>Thanks!
>Ed
>
>(remove NO from e-mail address to reply)
>
>Astronomy Software:  http://www3.gamewood.net/mew3/
>Astronomy Web Page:  http://www3.gamewood.net/astronomy/

Ed

(remove NO from e-mail address to reply)

Astronomy Software:  http://www3.gamewood.net/mew3/
Astronomy Web Page:  http://www3.gamewood.net/astronomy/


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

Date: Sun, 29 Jun 1997 21:13:40 GMT
From: Miten S Mehta <mehta@mama.indstate.edu>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: lastIndexOf ( String, SubStringRegex )
Message-Id: <Pine.LNX.3.93.970629154646.24484A-100000@mama.indstate.edu>

6/29/97


Hello,

Thanx for replying.  I am sorry for confusion.  here is the task to
accomplish:

I donot know what mail client connects to which mail server on my host as
I guess both pop and smtp are running.  Any way I guess both have this
common thing that any new mail will be as below:
>From .*<a blankline>

and it gets appened to /usr/var/spool/username file.

I just wanted to write script that would read the last new message and
extract it.  I was thinking of distributing it like news group but the
logic of mine has a flaw.  During the cron sleep there could be multiple
new messages so the ideal thing would be to use the filter-rules or
 .forward.

Any way the problem as a problem still remains as to how to find the last
match of a substring in string.  Looks like no decent function is there as
in java there is lastIndexOf but poor java does not have regex.

Hey, I was just playing with stuff so reply casually.  Bye.

Once again thanx for replying.

p.s. If you have a good pointer to cookies example for session management
and passwd authentication please direct me and oblige.  As I am not a sys
admin I would need some background on web server dir layout and cgi-bin
too.  hmmn need to learn web admin too :-0

Have a good day !!!

Best Regards,

Miten Mehta.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
Res:                                            |
Miten S Mehta                                   |
311 S Lasalle St, 39E,		                |
Durham, NC 27705                                |
Tel: 919 416 3889                               |             
e-mail: mehta@mama.indstate.edu                 |
resume url:                                     |
ftp://mama.indstate.edu/users/mehta/resume.html | 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             






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

Date: Sun, 29 Jun 1997 16:41:48 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Miten S Mehta <mehta@mama.indstate.edu>
Subject: Re: lastIndexOf ( String, SubStringRegex )
Message-Id: <Pine.GSO.3.96.970629163622.17728B-100000@kelly.teleport.com>

On Sun, 29 Jun 1997, Miten S Mehta wrote:

> I just wanted to write script that would read the last new message and
> extract it. 

[Meaning, from a user's mailbox file.] Open and flock the file, then you
can read through it looking for the last message. Since the beginning of
the last message will usually be near the end of the file, you could use
seek to start near the end and work backwards with additional seeking as
necessary.

> the logic of mine has a flaw.  During the cron sleep there could be
> multiple new messages 

Using flock may prevent new messages from being added, but it is something
to worry about.

> Any way the problem as a problem still remains as to how to find the last
> match of a substring in string.  

Perl has rindex, documented in perlfunc. That doesn't use a regular
expression, which your subject line seems to imply, but it works very
well.

> p.s. If you have a good pointer to cookies example for session management
> and passwd authentication please direct me and oblige.  

Start at this URL and go from there.  :-)

	http://www.yahoo.com/

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 29 Jun 1997 11:08:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Sandler <sandler@501.yc.yu.edu>
Subject: Re: Learning Perl
Message-Id: <Pine.GSO.3.96.970629110743.29224G-100000@kelly.teleport.com>

On Sun, 29 Jun 1997, Ben Sandler wrote:

> > error message of "perl1[4]: syntax error at line 5 : `;' unexpected"
> > if ($name eq "Chris") {
> >         print "Hello Chris! You smell terrific!\n"

> line above should and with ; (this is what is causing the error)

> > } else {

Actually, that's not the error; the last semicolon in a block is optional.
Thanks for trying, though!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 29 Jun 1997 11:10:05 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chester Wong <cpw10@columbia.edu>
Subject: Re: Learning Perl
Message-Id: <Pine.GSO.3.96.970629110913.29224H-100000@kelly.teleport.com>

On Sun, 29 Jun 1997, Chester Wong wrote:

> >if ($name eq "Chris") {
> >        print "Hello Chris! You smell terrific!\n"
> 
> you forgot a ";" at the end of that line.
> 
> >} else {

Actually that wasn't the error. The semicolon is optional after the last
(or only) statement of the block. Thanks for trying, though!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 29 Jun 1997 11:17:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: chris.deehan@east.sun.com
Subject: Re: Learning Perl
Message-Id: <Pine.GSO.3.96.970629111016.29224I-100000@kelly.teleport.com>

On Sat, 28 Jun 1997 chris.deehan@east.sun.com wrote:

> I am using the Korn shell and perl is located in /usr/dist/exe/perl.
> 
> I am copying the script right out of the book and I continually get the
> error message of "perl1[4]: syntax error at line 5 : `;' unexpected"

When Perl gives you an error message you don't understand, the best thing
is often to see what perldiag(1) says about it. And it says...

     syntax error at line %d: `%s' unexpected
         (A) You've accidentally run your script through the
         Bourne shell instead of Perl.  Check the <#!> line, or
         manually feed your script into Perl yourself.

So there's part of the problem.

> Here is the script:
> 
> #!/usr/dist/exe/perl

Well, that _looks_ okay. But are the #! characters the very first
characters in the file? That is, is that the very first line, and are
there no spaces, control characters, or other characters before that text
on the line?

If that's not it, maybe your system doesn't support the #!  notation. Try
running your script under Perl directly, with a command like 'perl
my_script' and you should be able to get it to work. (More details in the
perlrun manpage.) Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 29 Jun 1997 15:58:54 -0400
From: dave@nws.fsu.edu (David Faciane)
Subject: LWP:Simple anon ftp problem
Message-Id: <5p6epu$p9p@kate.nws.fsu.edu>


LWP::Simple works great for anonymous ftp sites that aren't too picky
about passwords but I can't seem to get it to work for those that
require an explicit joe@some.domain.

I tried this and it's not working:
  perl -MLWP::Simple -e	\
	'getprint "ftp://anonymous:me\@my.host\@ftp.some.where.com"';

I guess because of the dueling @ signs.

Any suggestions? I already RTFM'd, RTFF'd, and RTFD'd.


-- 
David Faciane                 |web: http://www.nws.fsu.edu/~dave	 
NOAA National Weather Service |Real-Time Worldwide Marine Weather Reports 
Tallahassee, FL               |  http://www.nws.fsu.edu/buoy	 
Sender of unsolicited commercial email agrees to pay me $500 for proofreading.


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

Date: 29 Jun 1997 22:52:35 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: LWP:Simple anon ftp problem
Message-Id: <hzps9qgh8.fsf@bergen.sn.no>

dave@nws.fsu.edu (David Faciane) writes:

> LWP::Simple works great for anonymous ftp sites that aren't too picky
> about passwords but I can't seem to get it to work for those that
> require an explicit joe@some.domain.
> 
> I tried this and it's not working:
>   perl -MLWP::Simple -e	\
> 	'getprint "ftp://anonymous:me\@my.host\@ftp.some.where.com"';
> 
> I guess because of the dueling @ signs.

Try to URL-encode the '@' (as '%40') in your mail address.  That
should make it:

perl -MLWP::Simple
     -e 'getprint "ftp://anonymous:me%40my.host\@ftp.some.where.com"';

-- 
Gisle Aas <aas@sn.no>


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

Date: 29 Jun 1997 23:08:46 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl 5.004_01 is available (binary for DOS, Win* and OS/2)
Message-Id: <5p6ptu$93e@agate.berkeley.edu>

In article <5p622a$a9c$1@nadine.teleport.com>,
Tim Bunce <timbo@ig.co.uk> wrote:
> The Perl development team is pleased to announce the release of
> Perl 5.004_01.  This is the first Maintenance Release for Perl 5.004.

For those who did not notice it yet, a binary EMX-compiled release
(with some additions(*)) is available from CPAN for a week already.  It
runs under DOS, Win* and OS/2 with EMX or RSX runtime.  Here is the
list of EMX-specific changes wrt the previous release (5.003_93):

after 5.004_01:
	flock emulation added (disable by setting env PERL_USE_FLOCK=0),
		thanks to Rocco Caputo (OS/2 only);
	RSX bug with missing waitpid circomvented;
	-S bug with full path with \ corrected.

(*) Additionally a REGEXP jumbo patch and MALLOC jumbo patch are applied.

Note also that an *experimental* prealpha release of Perl/Tk module
for PM (OS/2) is also available for download.

Ilya


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

Date: Sun, 29 Jun 1997 11:41:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim Hribnak <hribnak@nucleus.com>
Subject: Re: Perl and killing processes
Message-Id: <Pine.GSO.3.96.970629113658.29224M-100000@kelly.teleport.com>

On 28 Jun 1997, Jim Hribnak wrote:

> I run a perl script I got from someone, what it does is every 5 mins via
> crom it runs, connects to our portmasters and counts how many people are
> online, if for some reason it times out, the perl program will stick
> around, as well as the telnet that is spawns.. 

Maybe you should fix it so that it will not stick around. Failing that,
you could make it write its pid to a file when it starts. 

> I want to add something to this perl program that will check to see if 
> its running from the last time, and kill the process ID of the old one 
> and also kill the telnet session that the original process spawned  

So you'll want to write out the ID of the telnet session, as well. 
(Although you could telnet from perl with a module, so that you wouldn't
have another process and another pid to worry about.) 

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 29 Jun 1997 11:24:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: bglenn@swanmedia.com
Subject: Re: Problems with HTTP_REFERER
Message-Id: <Pine.GSO.3.96.970629112145.29224J-100000@kelly.teleport.com>

On Sun, 29 Jun 1997 bglenn@swanmedia.com wrote:

> the $ENV{'HTTP_REFERER'} variable is blank when the referer is from a
> *.cgi file extension.  Why is this happening.  

It is blank because of something outside of Perl. Perl won't affect that
variable; it only passes it on to your script. Perhaps you want to check a
CGI or server newsgroup (or their FAQs) to find out more. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 29 Jun 1997 21:57:30 GMT
From: csbrown@floater.com (Craig Brown)
Subject: Programming more, sleeping less. How do you stay awake?
Message-Id: <33c7da27.12533306@news.realnews.net>



Programmers Summary: I invented this great tasting stuff to keep me
awake during extended periods of coding. I  am making it available to
other programmers on the net.

The whole story:
Ive been a programmer/software engineer for over 19 years. After
leaving Lotus six years ago, I started my own company, Floater. To
create our product, I had to work as a contractor during the day and
code at night. The life style was really not much different then other
coding jobs that I had (Im sure 80-100 hour work weeks are something
that many of you have had experience with). Unreasonable deadlines
seem to be the norn in our industry.

Anyway, I sucked down a lot of coffee and Jolt Cola and  ate a lot of
junk food.  I tried the other caffeine delivery systems and found that
they either tasted like crap or upset my stomach. One day (while
falling a sleep at my computer) I got the idea to create a new
product. I mixed Salt Water Taffy, with Starbucks Espresso beans. It
tasted great! I then got some pure caffeine and added it to the mix.
It still tasted great! 

I got a local manufacture to produce a 35 lb. batch of the stuff and
gave it to my friends as gifts. Everybody liked it, so I decided to
make it available to programmers on the net. I call it Tasty Buzz
Taffy and you can get it from my web site. I promise you, it is the
best tasting caffeine delivery system in the world (with the exception
of maybe Kona or Jamaican Blue Mountain coffee).

I will continue to make it as long as you continue to buy it. It has
to be made in bulk, and all batches are produced in the same factory
that manufactures regular Salt Water Taffy for the gift shops on Cape
Cod.
You can learn more about it by my visiting my web site at
http://www.floater.com/catalog/stuff
You can order it 24 hours a day by calling (612) 229-4966 (this is a
service that I am paying to take orders).

Please let me know what you think. I can vary the flavor by adding or
subtracting espresso beans and flavoring. 

Regards,

Craig



Tasty Buzz Taffy

"If we didn't make it, it's not tasty"

You can order it 24 hours a day by calling 
(612) 229-4966 or order online at 
http://www.floater.com/catalog/stuff


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

Date: 29 Jun 1997 19:30:31 -0400
From: promo@orion.jumbo.com (Ed Tsigal)
Subject: Test Drive 1500 of the Best Software Titles
Message-Id: <5p6r6n$5k0@orion.jumbo.com>

Demo City, http://www.jumbo.com is a huge resource of over 1500
commercial Software demos that you can download directly to your 
computer for free trials.  It's a great place to check out the newest 
releases, beta versions, and the best commercial titles available today.

Demo City has seven sub-channels: Business, Internet, Desktop
Publishing, Multimedia, Games, Programming and Utilities, that
centralize the hundreds of Software Programs available on the Web.
There are demos for all operating systems -- From over 900 Software
companies!  Instead of having to comb through the Search Engines for a
particular type of Software Program, you can simply visit Demo City and
find exactly what you need in a fraction of the time.

http://www.jumbo.com



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

Date: Sun, 29 Jun 97 17:32:09 GMT
From: harold@spectra.net (Harold J. Fennell)
Subject: Update Access or Foxpro Database
Message-Id: <5p6646$l22$1@usenet87.supernews.com>

Hello.

I was wondering if there is a package that is available for updating a Access 
of Foxpro program without having to program with it in Perl.  The Perl would 
be run on a windows machine and runs either Access or Foxpro(haven't decided 
what machine to put it on).

I will be email the machine or some how get the information and then I need it 
put inot the database automatically.  Can this be done and how could it be 
done.

Thank you for any help in this matter.

Harold

-------------------------------------------------------------------------------------
-  Harold J. Fennell                  Phone: 607-693-3304        -
-  Advanced Research Labs      Fax: 607-693-4250            -
-  P.O. Box 56                         E-mail: harold@spectra.net-
-  Nineveh, NY 13813                                                       -
-  Internet Consultant                                                       -
-------------------------------------------------------------------------------------


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

Date: 29 Jun 1997 23:07:23 +0200
From: gator@cs.tu-berlin.de (Peter Daum)
Subject: using Perl's "open" on devices
Message-Id: <5p6iqb$1o7@swamp.bayern.net>

Hi,

I have to write some audio data to /dev/audio on a Linux
system. Unfortunately, it looks like Perl's "open" function
implicitly calls "lseek", provoking an "Operation not permitted"
error (same with FileHandle::fdopen and other workarounds I
tried). Thus, I ended up using POSIX::open and write, basically
writing C code in Perl.

Is there any more elegant solution, some way how to use Perl's
"normal" functions to work on special files? (The Perl
documentation doesn't seem to mention this problem)

Regards,
               Peter
-- 
     | Peter Daum (gator@cs.tu-berlin.de)        __o   (+49 30)
     | http://www.cs.tu-berlin.de/~gator       _'\<_  691 46 35
     | pgp messages welcome!                 _(_)/(_) ___________

                                                                 
                                                                 
                                                                 
                                                                 



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

Date: Sun, 29 Jun 1997 18:07:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Variable help please
Message-Id: <ECJuCs.61y@world.std.com>

citicentr@aol.com (CitiCentr) writes:

>I was hoping someone could help me with a quick problem- is there anyway
>in Perl to have one variable become part of another variable name?  For
>instance, if I wanted to test ($cat1 eq 1) but I wanted the 1 to be
>dependent on a variable $calendar (ie, if $calendar was 2 then the
>expression would be ($cat2 eq 1)...is that possible?

My first suggestion is to rethink what you want to do. Do you really
want to create and deduce variable names at runtime? or would you be
better off using an array.

$cat[1] and $cat[$calendar] instead of $cat1.

If you really need scalars, and can't use an array, then take a look
at perl's "symbolic references" construct in the perlref man page.

if(${"cat$calendar"} == 1) {}

The double quoted string "cat$calendar" is evaluated, and comes up
with a value. That value is then used as a reference to another scalar
and de-referenced with the ${} construct.

In older versions of perl you could achieve a similar effect using
typeglobs, but you shouldn't be concerned with that since I'm sure you
must be using a fairly current version of perl. If you ever have to
maintain older perl code, you may come accross it, so I figured I
should mention it.

Ignore any advice that suggests using eval() to come up with variable
names at runtime. eval is a much more time consuming operation than
either symbolic references or typeglobs. It is simply the wrong hammer
for the job. (There may be more than one way to do it, but not every
way is the right way.)


-- 
Andrew Langmead


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

Date: Sun, 29 Jun 1997 11:43:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Wayne Blick <wayne@cta-challenge.com.au>
Subject: Re: Zombie processes under system load
Message-Id: <Pine.GSO.3.96.970629114204.29224N-100000@kelly.teleport.com>

On Sun, 29 Jun 1997, Wayne Blick wrote:

> But, when several forks are required in say a 5 second period, the
> "reaper" code misses some child signals and they become zombies.

Hmmm... Maybe some of the forks are failing, although I can't see how that
would cause this behavior. Are you redoing the fork if it fails? If you
could post the code which forks, that could help. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 30 Jun 1997 11:25:41 +1000
From: Wayne Blick <wayne@cta-challenge.com.au>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Zombie processes under system load
Message-Id: <33B70B15.7DE8@cta-challenge.com.au>

This is a multi-part message in MIME format.

--------------5D1215A76CFF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks for your reply Tom.  I've attached some sample code for the
'client' and 'broker' this time.


> > But, when several forks are required in say a 5 second period, the
> > "reaper" code misses some child signals and they become zombies.
> 
> Hmmm... Maybe some of the forks are failing, although I can't see how that
> would cause this behavior. Are you redoing the fork if it fails? If you
> could post the code which forks, that could help. Thanks!


On my system, the child 'agents' are reaped successfully maybe 90% of
the time.  The rest quickly accumulate as zombies, until the 'broker' is
terminated.

Thanks again.

Wayne Blick

--------------5D1215A76CFF
Content-Type: text/plain; charset=us-ascii; name="broker.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="broker.pl"

#!/usr/bin/perl -w
#
# RUN THIS ONE FIRST
#
# broker.pl  (cut down example)
#
# The Broker is a known point for all inbound client
# requests.  An Agent is forked to perform a service.
#


use strict;
use IO::Socket;
use Carp;

# and, we better change this so the newsgroup can run code
#use Const;
sub TRUE { 1 };
### end


sub catch_int {
    print STDERR "Waiting for children to die...\n";
    sleep 10;
    exit;
};

sub catch_chld {
    my $waitpid = wait;
    print STDERR "Reaping pid $waitpid\n";
};

$SIG{INT}  = \&catch_int;
$SIG{CHLD} = \&catch_chld;

my $listen = IO::Socket::INET->new(
            Listen => 5,
            LocalAddr => 'localhost',
            LocalPort => '1100',
            Proto     => 'tcp',
            Reuse     => TRUE
            );

my $connect_num = 0;
my $sock;
my $pid;
while (TRUE)
{
    ++$connect_num;
    $sock = $listen->accept();
    $sock->autoflush( TRUE);

    if ( !defined( $pid = fork()) )
    {
        croak "cannot fork";
    }
    elsif ( $pid == 0)
    {
        # OK, this is the Agent - let's give 'em what they want

        print STDERR "another child\n";
        print $sock "yabba dabba doo $connect_num\n";  # dummy message

        $sock->close();
        exit;
    }
}


exit;


--------------5D1215A76CFF
Content-Type: text/plain; charset=us-ascii; name="client.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="client.pl"

#!/usr/bin/perl -w
#
# RUN THIS ONE NEXT
#
# client.pl  (cut down example)
#
# This Client simulates a flurry of requests to 
# the Broker.  We get responses from each Agent
# that the Broker forks.
#


use strict;
use IO::Socket;

# and, we better change this so the newsgroup can run code
#use Const;
sub TRUE { 1 };
### end


my $loop = 0;
my $sock;
print "Starting...\n";
while ( TRUE)
{
    ++$loop;

    $sock = IO::Socket::INET->new(
            PeerAddr  => 'localhost',
            PeerPort  => 1100,
            Proto     => 'tcp',
            );

    $sock->autoflush( TRUE);
    print $sock->getline(), "\n";

    $sock->close();
}

exit;


--------------5D1215A76CFF--



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 683
*************************************

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