[7061] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 686 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 30 13:27:16 1997

Date: Mon, 30 Jun 97 10:00:30 -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           Mon, 30 Jun 1997     Volume: 8 Number: 686

Today's topics:
     Re: <Writers Seeking Publication> (Matthew D. Healy)
     Anomaly in regexp handling <gabe@gabe.com>
     ANSWER - Re: Help with du called from Email or CGI; dou webmaster@lofcom.com
     Re: Attempt at a Guest Book (Chris Klugewicz)
     Re: changing caller's cwd (Quentin Fennessy)
     chat2.pl in Unix question <topo@pacific.net.sg>
     Re: Fun with ".cgi contained no blank line separating h <bryan@eai.com>
     Re: Help launching/controlling external application <clark@s3i.com>
     Help with script... <jheck@merck.com>
     Re: Help with script... <sfairey@adc.metrica.co.uk>
     Help...  OOP perl <jpm@iti-oh.com>
     Re: How do I remove spaces (or other chars) from a stri <jpm@iti-oh.com>
     How to add users to .htpasswd <vinbetro@vantek.net>
     Re: How to add users to .htpasswd (Jean-Damien Durand)
     interpolating a variable <yash@khemani.com>
     Linking old and new DBD-Oracle 32-bit object together w (Anton Dischner)
     Re: Oraperl using SQL*NetV2 (Anton Dischner)
     Re: Perl & SQL <Tim.Bunce@ig.co.uk>
     Perl lib version doesn't match exe and sockets (Tracy Bednar)
     Question: Output redirection <sannakka@ptc.com>
     Re: Question: Output redirection <sfairey@adc.metrica.co.uk>
     Re: Regexp with exclusion <jklein@alerts.co.il>
     Set uid and gid to 0 <rachel@cbogate.peel.edu.on.ca>
     Re: Set uid and gid to 0 <kperrier@Starbase.NeoSoft.COM>
     Re: Set uid and gid to 0 (Tracy Bednar)
     Sorting a two dimensional array (Ray Benjamin)
     Re: Sorting a two dimensional array <sfairey@adc.metrica.co.uk>
     Re: Sorting a two dimensional array <merlyn@stonehenge.com>
     Re: Sorting a two dimensional array <dean@tbone.biol.sc.edu>
     Uploading CGI's with a Mac (Bakshi2)
     Re: Zombie processes under system load <merlyn@stonehenge.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 30 Jun 1997 11:39:21 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: <Writers Seeking Publication>
Message-Id: <Matthew.Healy-3006971139210001@pudding.med.yale.edu>

In article <33b475c6.0@news1.ibm.net>, Litagent345@aol.com wrote:

 ...
> WOODSIDE INTERNATIONAL LITERARY AGENCY>>>
 ...
> Woodside, New York>>>>
 ...

Aaaack. This is an incredibly notorious spammer.  Before having anything
whatsoever to do with them, I would advise lurking on misc.writing for a
while, paying particular attention to postings with subject lines that
contain the strings "Woodside", "Woody", "Woodsiting", "Woodchuck", and
the like...
--------
Matthew.Healy@yale.edu           http://ycmi.med.yale.edu/~healy/
As of 26 Jun 1997, only 918 days until Y2K....
Any person with a phone line can become a town crier with a voice
that resonates farther than it could from any soapbox.
--The US Supreme Court, overturning the Communications Decency Act


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

Date: 30 Jun 1997 14:30:00 GMT
From: "Gabe Schaffer" <gabe@gabe.com>
Subject: Anomaly in regexp handling
Message-Id: <01bc8562$556a4b90$457985cd@falcon>

Can somebody please either confirm or deny that this is the correct behavior?

  'cdcde'=~/(c(d|e)+)+/;
  print qq('$1', '$2'\n);

has the output "'cde', ''", even though...

  'foocde'=~/(c(d|e)+)+/;
  print qq('$1', '$2'\n);

has the output "'cde', 'e'".

This is with Perl 5.004.

I recognize the second example to be the correct behavior, while I am
guessing that the first example demonstrates incorrect behavior.

Is it a bug?  If so, has it been fixed?
Please send me email if you know the answer(s).

Thanks,
Gabe


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

Date: Mon, 30 Jun 1997 11:36:55 -0600
From: webmaster@lofcom.com
Subject: ANSWER - Re: Help with du called from Email or CGI; doubled?
Message-Id: <867686190.5595@dejanews.com>

In article <867524011.13100@dejanews.com>,
  charlie@lofcom.com wrote:
>    Now I set up procmail to run the script when mail arrives to a specific
> address on my virtual server. Suddenly, the values are _doubled_.
>
>    Huh?

   (*sigh*) Now that I've shown my ignorance to the entire world...

  The answer is painfully obvious. du on my system doesn't accept the -k
switch, but _does_ use the BLOCKSIZE environmental variable. A simple
each %ENV showed clearly that for my shell, BLOCKSIZE was set to 1k,
where it was not set in the mail-spawned process. Simply setting
$ENV{BLOCKSIZE} = "1k" before the du fork handily solved the problem.

  My thanks to those who replied so patiently to what was in retrospect a
true "newbie" question, and to those who gently reminded me to
RTFManpages (and more carefully this time!).

         Charlie Summers

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Mon, 30 Jun 1997 13:03:34 GMT
From: ck@chesbay.com (Chris Klugewicz)
Subject: Re: Attempt at a Guest Book
Message-Id: <33b7acd3.468085@news3.his.com>

On Sun, 29 Jun 1997 12:58:59 -0400, bigmack <bigmack@erols.com> wrote:

>I have a problem.  I am trying to create a guest book, and it doesn't
>work.  I am using file 20lst05.pl to make a guest book.  However, it is
>not looking in the right directory for the file.  How do I change it? 
>It is following this path "http://www.erols.com/cgi-bin/gestbook.pl" and
>I have the code under
>"http://www.erols.com/bigmack/cgi-bin/gestbook.pl".  Can someone help me
>on this?  I'll be sticking around for awhile, so if you need more
>information, just ask for it.

It doesn't look like you're pointing the browser to the right
directory.  If you have your own 'cgi-bin' directory, generally the
URL looks something like

   http://www.somewhere.com/~yourname/cgi-bin/whatever.cgi

not what you've posted above.

In your case it probably should look like this:

   http://www.erols.com/bigmack/cgi-bin/gestbook.pl

(Incidentally, is the misspelling of the Perl script name intentional?
Also, I tried all of these various URLs and none of them work.  It
might be that you are not allowed to install your own CGI scripts at
your ISP -- a common restriction.  You might want to check with your
ISP to investigate their policies.)



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

Date: 30 Jun 1997 13:03:06 GMT
From: quentin@remington.amd.com (Quentin Fennessy)
Subject: Re: changing caller's cwd
Message-Id: <5p8aqa$haq$1@amdint2.amd.com>

In article <33B6AD31.26320FC9@pobox.com>,
root@snidget.jumeaux.org <damon@pobox.com> wrote:
>something i've simply never tried to do before and now i find myself
>stumped.  what's involved in changing the working directory of the shell
>that ran perl?  i.e., i want my program to take me to a new directory. 
>(i'm trying to replace an old DOS program called 'go' under linux - i'm
>sick of typing 'cd /usr/X11R6/lib/X11/fvwm2' and the like, even *with*
>filename completion ;)

>From perlfaq8:

     I {changed directory, modified my environment} in a perl
     script.  How come the change disappeared when I exited the
     script?  How do I get my changes to be visible?
 
     Unix
         In the strictest sense, it can't be done -- the script
         executes as a different process from the shell it was
         started from.  Changes to a process are not reflected in
         its parent, only in its own children created after the
         change.  There is shell magic that may allow you to fake
         it by eval()ing the script's output in your shell; check
         out the comp.unix.questions FAQ for details.
 

-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: Mon, 30 Jun 1997 21:05:44 +0800
From: Topo Computers <topo@pacific.net.sg>
Subject: chat2.pl in Unix question
Message-Id: <33B7AF28.FF6@pacific.net.sg>

If you have time please answer this question.

I work via telnet on a hosting server. Recently I have downloaded a
script which uses chat2.pl. Executing command
&chat::open_proc("anycommand") I got a message:

stty: stdout appears redirected, but stdin is the control descriptor:
Undefined error: 0

What is the problem? Hope I don't ask nonsense.


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

Date: Mon, 30 Jun 1997 11:04:44 -0500
From: Bryan Hart <bryan@eai.com>
Subject: Re: Fun with ".cgi contained no blank line separating header and data"
Message-Id: <33B7D91C.794B@eai.com>

Shelle wrote:
> 
> mupe@desk.nl (M. muPe) wrote:
> >shelle@interaccess.com (Shelle) wrote:
> >>OK, we're dealing with a Win95 (rev. b) system, running WebSite 1.1e, and Perl
> >> for Win32 5.003_07:
> >>
> >>This Server Error 500 message has plagued me for weeks with various scripts
> >>Although I'm feeling somewhat vindicated in that I can see the content-type
> >>info followed by 2 spaces print from the DOS command line, it really doesn't
> >>help too much to kill the problem.
> >
> >Folowed by two spaces?? It must be 2 new lines "\n\n"
> >
> >Hope your problem was as simple as that.
> 
> Alas it was not....  I stated incorrectly in my original post and apologize
> for the error humbly.  Indeed I did have the necessary "\n\n" and was looking
> at the blank line.
> 

You mention it's a Win95 system, have you tried using "\r\n\r\n" instead
of "\n\n"?  Non-unix systems sometimes use different variants of \n and
\r to denote newlines.

Bryan

-- 
-------------------------------
|  Bryan Hart                 
|  Network Products Engineer  
|  Engineering Animation Inc. 
|  Phone: (515) 296-5979
|  Fax: (515) 296-7025
|  Email: bryan@eai.com              
|  Web: http://www.eai.com/                          
-------------------------------
"A conclusion is simply the place where you got tired of thinking"


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

Date: 30 Jun 1997 11:29:47 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: Help launching/controlling external application
Message-Id: <dzps8kt1w.fsf@s3i.com>


david@csol.com (David Corbin) writes:
> Clark Dorman <clark@s3i.com> wrotc:
> 
> >david@csol.com (David Corbin) writes:
> >> I am trying to launch an application (tcpdump), and be able to kill it
> >> after a certain time.  I'm using Fork/Exec, and that launching part
> >> works fine.  But, if I attempt redirect the output to /dev/null, then
> >> it launches a shell first, which launches the tcpdump.  This wouldn't
> >> be a problem, but when I attempt to KILL the process I created, the
> >> shell dies, but tcpdump doesn't.  (well, it seems that it will if I
> >> use SIGHUP, but that seems to do REAL bad things to my system).
> >> 
> >> I need either 1) a better way to kill these two process, or 2) someway
> >> to redirect the tcpdump stdout/stderr without launching a shell.
> 
> >What you need to do is to kill the process and all of it's children,
> >not just the process itself.  The secret is to kill the entire process
> >group, using - before the id of the group.  Normally, the parent would
> >die, but you make the parent ignore the signal.  Try the following or
> >some variation thereof (time_waster.sh is just a shell script that
> >calls a C program that takes a long time to run):
> 
> 
> >-- 
> >Clark Dorman				"Evolution is cleverer than you are."
> >http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick
> 
> And on further reflection...."you've got to be kidding".  What if I
> want to launch several process, but kill them selectively?
> 
> David Corbin

I don't think that you can do this if your child processes have
sub-processes unless:
	1.  you use POSIX, and I don't know anything about it; or
	2.  you keep track of all process ids; or
	3.  go and find all the processes and kill them

I am not an expert, but here goes my explanation.  Every process has
it's own process id; however, there is only one process group for the
entire set of processes.  You originally have one parent, and it can
fork off several children.  If you kill the child processes
individually, they die as you would expect.  However, if a child
process has a sub-process, then the sub-process will not die if you
kill the child.  

The solution that I posted before sets the parent to ignore HUP and
then kill the entire process group.  That reaps all the sub-processes.
If you do this with multiple child processes, then all the children
and their sub-processes die.

Does anyone else have a solution to this problem? 

--
Clark E. Dorman				"Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick


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

Date: Mon, 30 Jun 1997 10:13:21 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: Help with script...
Message-Id: <33B7BF01.41C6@merck.com>

I am trying to write a script that will go through a file looking for
nested comment lines.  Ie find a "/*" then if it finds another "/*"
before finding a "*/" replace the second instance with some character
sequence.  This way we will know where the nested comments were by
searching for the specific replacement string.
	It is funny this script will search and fix these nested comments in
the actual PERL source, so that a 64-bit complile will not throw tons of
warnings....:-)

	Any help would be greatly appreciated.  
James

--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck


       The contents of this message express only the sender's opinion.
       This message does not necessarily reflect the policy or views of
       my employer, Merck & Co., Inc.  All responsibility for the statements
       made in this Usenet posting resides solely and completely with the
       sender.


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

Date: Mon, 30 Jun 1997 16:11:38 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: jheck@acm.org
Subject: Re: Help with script...
Message-Id: <33B7CCAA.41C6@adc.metrica.co.uk>

James J. Heck wrote:
> 
> I am trying to write a script that will go through a file looking for
> nested comment lines.  Ie find a "/*" then if it finds another "/*"
> before finding a "*/" replace the second instance with some character
> sequence.  This way we will know where the nested comments were by
> searching for the specific replacement string.
>         It is funny this script will search and fix these nested comments in
> the actual PERL source, so that a 64-bit complile will not throw tons of
> warnings....:-)

If thats the case and the comments are of no importance to you then you
could just lose all comments. From the FAQ:

perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c

Simon


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

Date: 30 Jun 1997 14:35:58 GMT
From: "Joshua Marotti" <jpm@iti-oh.com>
Subject: Help...  OOP perl
Message-Id: <01bc8563$22badf60$36601ec6@bach>

help...
I have a script that opens a file and saves info into several objects.  If
I use an object more than once, the new object still contains all the
values that the old object has.  I want both pieces of info, but I want
them to be in separate objects...
OK... I can't explain this well... lemmie try again...
I am searching for classes in a source file...
My object is "class"... 
my new function looks like this:
package Class;
sub new
{
   my $type = shift;
   my $self;
   $self = shift;
   my @child_mf;
   my @child_dm;
   my @typedef;
   my $template_info;
   my %doctag;
   return bless \$self, $type;
}

(all the my's are, are prototypes for the attributes of the object)...
I still want the class info, and I need to declare a new class, but when I
do, the new class's attributes are the same as the last classes...
In general - how do I individualize my objects?
If you don't understand what I am trying to get accross, please reply
saying so, and I'll try to explain better...
Thanks for your time,
Josh



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

Date: 30 Jun 1997 16:29:48 GMT
From: "Joshua Marotti" <jpm@iti-oh.com>
Subject: Re: How do I remove spaces (or other chars) from a string etc?
Message-Id: <01bc8573$0a6f70a0$36601ec6@bach>

hmmm... I'd say 
$foo = s/\s//g; #substitute \s (whitespace character) to nothing
globally...
where $foo is your string.
--
Josh Marotti - OOP attempter...


X <eeiX@eei.ericsson.se> wrote in article
<33B7D851.4E42@eei.ericsson.se>...
> I'm only starting this language so no sniggering if this seems pityfully
> easy!!!
> 
> For example say I wanted to remove the spaces from the following line:
> 
> 152 41-cax 102 577
> 


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

Date: Mon, 30 Jun 1997 09:57:53 -0500
From: "Vince Betro" <vinbetro@vantek.net>
Subject: How to add users to .htpasswd
Message-Id: <5p8hqb$9nc$1@news.socomm.net>


How do I add users and passwords to an .htpasswd file using the htpasswd
program?  I am using a PERL script on a UNIX server.


Jeff Betro
vinbetro@vantek.net





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

Date: Mon, 30 Jun 1997 15:27:38 GMT
From: ddurand@hpplus02.cern.ch (Jean-Damien Durand)
To: "Vince Betro" <vinbetro@vantek.net>
Subject: Re: How to add users to .htpasswd
Message-Id: <ECLHM2.Hzt@news.cern.ch>


> How do I add users and passwords to an .htpasswd file using the htpasswd
> program?  I am using a PERL script on a UNIX server.

  Hmmm... Answers to httpd question you'll find in a httpd location...
What about http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html ?

  Jean-Damien.
--
       *******************************************************
       *   Jean-Damien Durand (Jean-Damien.Durand@cern.ch)   *
       *         www : http://wwwcn.cern.ch/~ddurand/        *
       *******************************************************


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

Date: Mon, 30 Jun 1997 11:30:37 -0400
From: Maverick <yash@khemani.com>
Subject: interpolating a variable
Message-Id: <33B7D11D.7B1A@khemani.com>

hi folks,

say you have:

$var0 = '\n';

say you now wany:

$var1 = <interpolated value of $var0>

how might i do this?

thanks!
yash


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

Date: Mon, 30 Jun 1997 15:44:37 +0200
From: dischner@med.uni-muenchen.de (Anton Dischner)
Subject: Linking old and new DBD-Oracle 32-bit object together with SGI
Message-Id: <dischner-ya02408000R3006971544370001@news.lrz-muenchen.de>

Hi netters,

i tried to install DBD-Oracle.0.46 on a Challenge L RM10000 Irix 6.2.
When i do a 'make test' i get:

<-- cc -n32 -L/usr/local/lib -L/usr/lib32 -L/lib32  -o perl  ./perlmain.o 
/usr/local/lib/perl5/IP25-irix/5.004/CORE/libperl.a
/usr/local/lib/perl5/IP25-irix/5.004/auto/DynaLoader/DynaLoader.a 
 ./blib/arch/auto/DBD/Oracle/Oracle.a `cat
 ./blib/arch/auto/DBD/Oracle/extralibs.all` -lm -lc 

--> ld32: FATAL 112: cannot link old 32-bit object with -n32 link:                       
/oracle/app/oracle/product/7.3.2/lib/libclient.a(ofen.o).

When i remove the -n32 flag:

<-- cc -L/usr/local/lib -L/usr/lib32 -L/lib32  -o perl  ./perlmain.o 
/usr/local/lib/perl5/IP25-irix/5.004/CORE/libperl.a
/usr/local/lib/perl5/IP25-irix/5.004/auto/DynaLoader/DynaLoader.a 
 ./blib/arch/auto/DBD/Oracle/Oracle.a `cat
 ./blib/arch/auto/DBD/Oracle/extralibs.all` -lm -lc 

--> cc ERROR:  /usr/lib64/cmplrs/ld32 returned non-zero status 1
ld: FATAL 113: cannot link new 32-bit object without -n32: /usr/lib32/crt1.o.

Is there a solution to mix old and new 32-bit objects ?
Any other ideas ?

Your help is highly appreciated,
kind regards,

Toni

-- 
A. Dischner, SGI&AIX sysadmin, Oracle DBA       | Don't let friends
Institut fuer Klinische Chemie                  | use WinDose
Klinikum Grosshadern                            | Just say NO. 
Ludwig Maximilians Universitaet Muenchen,  GER  | Please remove            
Marchioninistr.15 81366 Muenchen 49-89-70953202 | _NO_SPAM for email.


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

Date: Mon, 30 Jun 1997 16:21:41 +0200
From: dischner@_NO_SPAM_med.uni-muenchen.de (Anton Dischner)
Subject: Re: Oraperl using SQL*NetV2
Message-Id: <dischner-ya02408000R3006971621410001@news.lrz-muenchen.de>

In article <33B2A403.587F@lhsystems.com>, Wolfgang Becker
<wolfgang.becker@lhsystems.com> wrote:

> Hi,
> I have a problem connect to database via SQL*NetV2; I reach only a local
> database.
> I'm using oraperl 2.4, perl 4.036 on hp-unix box (9.07) and Oracle
> 7.2.3..
> In some of your mails I read, the usage of oraperl is not state of the
> art any more - what can I work with instead. Is the DBD / DBI solution
> the wright way or is their a possibility to continue with oraperl. 
> Who can help me to solve this problem.
> 
> Wolfgang
Hi Wolfgang,

i installed Perl 5.004 and DBD-Oracle 0.46 and DBI o.84 on a IBM RS6000 AIX
3.2.5.1.

I was able to run this:

#!/usr/bin/perl -w
#
# connect.pl

use DBI;

$dbh = DBI->connect('LADA', 'scott', 'tiger', 'Oracle');
#$dbh = DBI->connect('LADA', 'scott@remote.world', 'tiger', 'Oracle');

die unless $dbh;

$cursor = $dbh->prepare("select your_item from your_table");
#$cursor = $dbh->prepare("select your_item from your_table\@your_db_link");

$cursor->execute;

while ($field = $cursor->fetchrow) {
   print(Field: $field\n";
}
$cursor->finish;
$dbh->disconnect;
exit;

Whatch out for typos, i hope you get the idea,
Please mail me if i was too fluppy,

Kind regards,

Toni

PS: LADA is my instance-name, remote.world is your remote-instance
see tnsnames.ora for this.

-- 
A. Dischner, SGI&AIX sysadmin, Oracle DBA       | Don't let friends
Institut fuer Klinische Chemie                  | use WinDose
Klinikum Grosshadern                            | Just say NO. 
Ludwig Maximilians Universitaet Muenchen,  GER  | Please remove            
Marchioninistr.15 81366 Muenchen 49-89-70953202 | _NO_SPAM for email.


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

Date: Mon, 30 Jun 1997 13:20:41 GMT
From: Tim Bunce <Tim.Bunce@ig.co.uk>
Subject: Re: Perl & SQL
Message-Id: <ECLBqH.Cn8@ig.co.uk>

In article <33B345DD.70FC@trifox.com>, Bob Eisner  <boei@trifox.com> wrote:
> Michael Polikoff wrote:
> > 
> > I'm currently working on a databasing project in which I'm designing an
> > applications interface in HTML.  In order to interface with the database
> > (Oracle), I need to write CGI scripts with embedded SQL.  I know this
> > can be accomplished with C or Visual Basic, but I don't have time to
> > learn a new language.  Does anyone know how this could be done with
> > Perl?
> > 
> > Desperate for any help anyone could give me -- even a link to a good
> > source of info.  Thanks.
> > 
> > Mike Polikoff
> > michael@uss.net
> > mpolly@miint.net
> 
> Hi Mike,
> 
> Trifox has a product, VORTEXperl.  It talks to multiple RDBMS
> and supports Oracle.  It uses Perl Sockets so there is no need
> to re-build the Perl runtime.
> 
> VORTEXPerl provides a simple interface for Perl applications to
> access all leading relational and legacy databases via the
> VORTEX database access and performance boosters, like
> VORTEXaccelerator, the industry-leading high performance
> transaction process monitor. With VORTEXPerl you can quickly
> access DBMS information from CGI applications and spend your
> time making your application great without bothering with DBMS
> details. 
> 
> You can obtain an evaluation copy of VORTEXperl from our WEB site
> at http://www.trifox.com/j/vortex/vtxperl.html
> 
> Regards,
> 
> Bob Eisner
> 408 369-2392

[Ignoring the fact that advertising commercial products in comp.*
newsgroups is not good netiquette...]

The standard Perl DBI does pretty much the same thing, is used by
thousands of people and web sites around the world, and is FREE.

See http://www.hermetica.com/technologia/DBI for more details.

Tim.



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

Date: Mon, 30 Jun 1997 15:52:15 GMT
From: spectran@netcom.com (Tracy Bednar)
Subject: Perl lib version doesn't match exe and sockets
Message-Id: <spectranECLIr3.42u@netcom.com>

What is the trick to be able to do socket programming
with perl?  I've tride the header conversion program with
no luck.

Now I'm trying the Socket module, but am getting the following error:

Perl lib version (5.003) doesn't match executable version (5.00401)

I just installed the newest perl.  Did I make an error on the install?

The os is Linux 2.0.27, on an intel chip.  Who can give me the 
easiest way to setup the necessary perl socket files?

Thnx!

 - T


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

Date: Mon, 30 Jun 1997 10:03:29 -0600
From: Sudhakar Sannakkayala <sannakka@ptc.com>
Subject: Question: Output redirection
Message-Id: <33B7D8D1.E48@ptc.com>

Hi,
	I'm trying to redirect the some stuff from the STDERR to a
file. 
Eg. example.pl >& filename

This works ... But if I call "system("example.pl >& filename");" from
another perl script it gives me an error 
"sh: filename: Generated or received a file descriptor number that is
not valid." 

Please enligthen me 

Thanks,
Sudhakar.


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

Date: Mon, 30 Jun 1997 17:34:19 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Sudhakar Sannakkayala <sannakka@ptc.com>
Subject: Re: Question: Output redirection
Message-Id: <33B7E00A.446B@adc.metrica.co.uk>

Sudhakar Sannakkayala wrote:
> 
> Hi,
>         I'm trying to redirect the some stuff from the STDERR to a
> file.
> Eg. example.pl >& filename
> 
> This works ... But if I call "system("example.pl >& filename");" from
> another perl script it gives me an error
> "sh: filename: Generated or received a file descriptor number that is
> not valid."
> 
> Please enligthen me
> 
> Thanks,
> Sudhakar.

See the FAQ at www.perl.com which answers your question in detail.
Just search for STDERR.

Simon

BTW: Although this should never have been posted ;) for future reference
if this had been a valid question ( i.e. one not answered in the FAQ )
you should only post such questions to comp.lang.perl.misc; unless of
course they are specific to the other news groups ( again this is all
answered very nicely in the FAQ ).


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

Date: Mon, 30 Jun 1997 16:05:56 +0300
From: Joe Klein <jklein@alerts.co.il>
Subject: Re: Regexp with exclusion
Message-Id: <Pine.SOL.3.95.970630155818.21973d-100000@cain.alerts.co.il>

Well, I wouldn't have dreamt of attempting a RE for this before starting
to read Friedl's book, but here's one that works:

$line = '   hello   world "dab   dab dab"  more if "daba   daba "  less '; 

$line =~ s/([^"]+)|("[^"]*")/$2 or (($x = $1) =~ tr@ @@s, $x)/eg;

print "<$line>\n";


produces

< hello world "dab   dab dab" more if "daba   daba " less >

and that's after only reading the first 128 pages!!! What a great book!!!

Joe Klein
News Alert

> Per Olesen typed before Poison Ivy kissed him:
> 
> : Hello
> 
> : I need a way to substituate multi whitespace with 
> : single whitespace globally in a string. BUT. Everything
> : in the string, which is enclosed within " must NOT 
> : participate in the substitution.
> 
> : example:
> 
> : $line = 'hello   world "dab   dab   dab"   more';



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

Date: Mon, 30 Jun 1997 10:51:39 -0400
From: Rachel Mackenzie <rachel@cbogate.peel.edu.on.ca>
Subject: Set uid and gid to 0
Message-Id: <33B7C7FB.7498F327@cbogate.peel.edu.on.ca>

Is it possible to set the uid or gid in perl to root???? and how???






thanks
rach


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

Date: 30 Jun 1997 10:18:31 -0500
From: Kent Perrier <kperrier@Starbase.NeoSoft.COM>
Subject: Re: Set uid and gid to 0
Message-Id: <csen9kqfug.fsf@Starbase.NeoSoft.COM>

Rachel Mackenzie <rachel@cbogate.peel.edu.on.ca> writes:

> Is it possible to set the uid or gid in perl to root???? 

Depends on your version of unix.  Most modern versions of unix do not
allow scripts to run suid root.  Programs can run suid root, though.

>and how???

If your verison of unix allows suid scripts then do the following (as root):

chown root <script name>
chmod 4755 <script name>

Kent
-- 
Kent Perrier                             kperrier@neosoft.com 
Corporations don't have opinions, people do.  These are mine.


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

Date: Mon, 30 Jun 1997 15:42:18 GMT
From: spectran@netcom.com (Tracy Bednar)
Subject: Re: Set uid and gid to 0
Message-Id: <spectranECLIAI.296@netcom.com>


Yes, but if you don't have the correct privileges an error will
be returned.

Check out $<, and $>

- T
Rachel Mackenzie (rachel@cbogate.peel.edu.on.ca) wrote:
: Is it possible to set the uid or gid in perl to root???? and how???






: thanks
: rach


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

Date: Mon, 30 Jun 1997 11:13:49 -0400
From: rbenjami@packet.net (Ray Benjamin)
Subject: Sorting a two dimensional array
Message-Id: <MPG.e2197335f403d98989680@news.packet.net>

Hi,

I've looked all the places I can think of and read about sort in the 
camel book, but I still can't get sort to sort my two dimensional array.

I have a two-dimensional array that has a string in the first field and a 
score in the second fields.  I'd like to sort the array by the score.  I 
tried the following sort routine:

sub byscore { a$[1] <=> b$[1] }

but that didn't seem to work.

The array is:

@thearray = (
["string", 0],
["another string", 6],
etc.
)

I call the sort with the line:

@sortedarray = sort byscore @thearray;

I get a result back, but it isn't sorted.

I'd appreciate any help I can get.
please reply via email to rbenjami@packet.net

Thanks,
   Ray Benjamin
   rbenjami@packet.net


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

Date: Mon, 30 Jun 1997 16:52:14 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Ray Benjamin <rbenjami@packet.net>
Subject: Re: Sorting a two dimensional array
Message-Id: <33B7D62E.2781@adc.metrica.co.uk>

Ray Benjamin wrote:
> 
> Hi,
> 
> I've looked all the places I can think of and read about sort in the
> camel book, but I still can't get sort to sort my two dimensional array.
> 
> I have a two-dimensional array that has a string in the first field and a
> score in the second fields.  I'd like to sort the array by the score.  I
> tried the following sort routine:
> 
> sub byscore { a$[1] <=> b$[1] }
> 
> but that didn't seem to work.
> 
> The array is:
> 
> @thearray = (
> ["string", 0],
> ["another string", 6],
> etc.
> )
> 
> I call the sort with the line:
> 
> @sortedarray = sort byscore @thearray;
> 
> I get a result back, but it isn't sorted.
> 
> I'd appreciate any help I can get.
> please reply via email to rbenjami@packet.net
> 
> Thanks,
>    Ray Benjamin
>    rbenjami@packet.net

Your problem here is that $a and $b in the sort routine are going to be
array references so you will need to derefernce them when you do the
comparison.
Try the following line for your sort:

@sortedarray = sort { $a->[1] <=> $b->[1] } @thearray;

Simon


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

Date: 30 Jun 1997 09:39:33 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: rbenjami@packet.net (Ray Benjamin)
Subject: Re: Sorting a two dimensional array
Message-Id: <8cg1u09ha2.fsf@gadget.cscaper.com>

>>>>> "Ray" == Ray Benjamin <rbenjami@packet.net> writes:

Ray> I've looked all the places I can think of and read about sort in the 
Ray> camel book, but I still can't get sort to sort my two dimensional array.

Well, there's really no such thing as a two-dimensional array in Perl,
and the only person that argues to the contrary isn't reading clp.misc
any more. :-)

Ray> I have a two-dimensional array that has a string in the first field and a 
Ray> score in the second fields.

Well, according to your data below, you have a list of listrefs, each
sub-list being a two-element tuple.  It's essentialy to name the
daemon-beast before killing it....

Ray>   I'd like to sort the array by the score.  I 
Ray> tried the following sort routine:

Ray> sub byscore { a$[1] <=> b$[1] }

Yeah, I can't imagine that even compiling, let alone working.  In
fact, it *didn't* for me.

Ray> but that didn't seem to work.

No kidding? :-)

Ray> The array is:

Ray> @thearray = (
Ray> ["string", 0],
Ray> ["another string", 6],
Ray> etc.
Ray> )

Ray> I call the sort with the line:

Ray> @sortedarray = sort byscore @thearray;

Ray> I get a result back, but it isn't sorted.

Of course.  OK, let's take a look.  In the sortsub, $a is a listref,
and $b is a listref.  @$a is therefore the list being pointed at, and
$$a[0] is the first element of that list, but that's ugly, so we'll
use the $a->[0] form instead.  But you wanted it sorted by the
second element, and that'd be $a->[1].  (And likewise for $b.)

So, the sortsub should be:

	sub sortsub { $a->[1] <=> $b->[1] }

And if you want to sort first by numbers, and then fall back to sorting
by names if the numbers are the same, just one more step:

	sub sortsub { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] }

For more examples of this, check out my Unix Review columns at
http://www.stonehenge.com/merlyn/UnixReview/.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 427 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 30 Jun 1997 12:45:02 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
To: rbenjami@packet.net (Ray Benjamin)
Subject: Re: Sorting a two dimensional array
Message-Id: <m17mfcghv5.fsf@nauplius.psc.sc.edu>

[Courtesy cc sent by email]

rbenjami@packet.net (Ray Benjamin) writes:
> Hi,
> 
> I've looked all the places I can think of and read about sort in the 
> camel book, but I still can't get sort to sort my two dimensional array.
> 
> I have a two-dimensional array that has a string in the first field and a 
> score in the second fields.  I'd like to sort the array by the score.  I 
> tried the following sort routine:
> 
> sub byscore { a$[1] <=> b$[1] }
 ...
> @thearray = (
> ["string", 0],
> ["another string", 6],
> etc.
> )
 ...
> @sortedarray = sort byscore @thearray;
> 
> I get a result back, but it isn't sorted.
 ...


How about:

    #!/usr/local/bin/perl -w
    # Always, always use the "-w" flag for better warnings
    
    sub byscore { $$a[1] <=> $$b[1] }  # You need to dereference appropriately
    
    @thearray = (
    ["string", 0],
    ["another string", 6],
    );
    
    @sortedarray = sort byscore @thearray;
    
    foreach (@sortedarray) {
        print "$$_[0] $$_[1]\n";       # similar dereferencing here
    }
    
    # Alternately, just dereference the array and let "print" do the work
    foreach (@sortedarray) {
        print "@$_\n";                 
    }                                  

Key items:

Use the "-w" flag to perl to get better error messages. 

The syntax within the initial sub byscore is illegal and should have
generated a syntax error -- I'm guessing that you transposed the
location of the "$" in writing this up for the Net.

A key thing to look up will be the subject of references in Perl.  The
arrays within the array are addressed by reference -- hence the "$$"
dereferencing to get at the scalars. See the "perlref" document that
comes with the Perl distribution.

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


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

Date: 30 Jun 1997 13:21:33 GMT
From: bakshi2@aol.com (Bakshi2)
Subject: Uploading CGI's with a Mac
Message-Id: <19970630132101.JAA13455@ladder01.news.aol.com>

I have tried to upload some scripts to my UNIX server. When I tried to
execute it, I got an "error 500." I think this may partly be the fault of
the mac, but I'm not sure. I did "chmod 755" the script and also uploaded
in: RAW DATA ASCII TEXT BINARY. Any advice please e-mail: bakshi2@aol.com


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

Date: 30 Jun 1997 08:23:20 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Wayne Blick <wayne@cta-challenge.com.au>
Subject: Re: Zombie processes under system load
Message-Id: <8cd8p4w1w7.fsf@gadget.cscaper.com>

>>>>> "Wayne" == Wayne Blick <wayne@cta-challenge.com.au> writes:

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

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

Wayne> $SIG{CHLD} = \&catch_chld;

Yes, of course, based on your code, I'd *expect* zombies to accumulate
under heavy system load.

The SIGCHLD "stack" is one-bit deep.  If two kids go away at precisely
the same moment, you get only one call to your subroutine.  When some
mutters "UNIX signals are unreliable", this is precisely what they are
pointing at: it's just one bit!  That means the second kid is just
gonna hang around, to get picked up when the *third* kid dies and the
second SIGCHLD is handled.

You need to wait for potentially multiple kids on each SIGCHLD.
Extrapolating from perlipc(1) and perlfunc(1), the proper reaper is:

	use POSIX ":sys_wait_h";

	sub REAPER {
		{
			my $kid = waitpid(-1, WNOHANG);
			redo if $kid != -1;
		}
	}

Give that a try.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 428 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

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

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