[6611] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 236 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 4 20:07:44 1997

Date: Fri, 4 Apr 97 17:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 4 Apr 1997     Volume: 8 Number: 236

Today's topics:
     Re: [Win32] "Error: parse exception" loading module (Ad <bmehling@uci.edu>
     Re: [Win32] "Error: parse exception" loading module (Ad (Nathan V. Patwardhan)
     Help with Associative Array (Kevin Murphy)
     How Do I... <bradenb@ibm.net>
     Re: How to extract string starting with n characters? <jim.michael@gecm.com>
     Re: How to get key from value in a %VAR ("John Dallman")
     Re: How to get key from value in a %VAR <rootbeer@teleport.com>, Tom Phoenix <rootbeer@teleport.com>
     Netscape and File Upload <nrstrc9@nortel.ca>
     Re: New Microsoft Perl Product (fwd) <alasdairt@private.nethead.co.uk>
     Re: Ousterhout and Tcl lost the plot with latest paper <drs1004@cl.cam.ac.uk>
     Re: Perl and permissions (Matthew Cravit)
     re: Perl listserve? <rd19@cornell.edu>
     PROBLEM:  Can't call method "import" in empty package < (Curtis Hrischuk)
     Re: Simple array question by newbie... <lewis@dnai.com>
     Re: Starting, Suspending, and Restarting a Child <dorman@s3i.com.anti-spam>
     Re: string comparision (Ilya Zakharevich)
     Re: symbolic reference doesn't work with arrays? (David Alan Black)
     VMS Perl question <Liyun.Wang.1@gsfc.nasa.gov>
     Re: Wildcards for a list of filenames ("John Dallman")
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 04 Apr 1997 13:41:49 -0800
From: Ben Mehling <bmehling@uci.edu>
Subject: Re: [Win32] "Error: parse exception" loading module (AdminMisc)?
Message-Id: <3345759D.1FAD@uci.edu>

Nathan V. Patwardhan wrote:
> 
> Ben Mehling (bmehling@uci.edu) wrote:
> 
> : We are trying to get Win32::AdminMisc (Dave Roth's added features to the
> : NetAdmin module) on our NT4(SP1a) Server.  We haven't even gotten the
> : module to load yet so I am thinking there is something wrong with our
> 

> $foo = (function($param))[1];
> 
> where something like
> 
> ($bar, $foo) = function($param);

Thanks for the reply, however I am not sure that this is my problem.  I
can not even get the module to load - as I mentioned, the script parse
errors when trying to load the module.  I haven't even gotten it to
"compile" when I try to "use Win32::AdminMisc", but when I # that out
the script runs fine...

So I am thinking its not a code problem (with my script), but with my
version of perl, my install of the module, or with AdminMisc itself -
although I would think people would have complained earlier AND it would
end up in a FAQ.

Anyone got an idea?

Ben

http://www.gsm.uci.edu/~bmehling/perl
http://www.gsm.uci.edu/~bmehling/nt


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

Date: 4 Apr 1997 23:44:19 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: [Win32] "Error: parse exception" loading module (AdminMisc)?
Message-Id: <5i43oj$9ss@fridge-nf0.shore.net>

Ben Mehling (bmehling@uci.edu) wrote:

: Thanks for the reply, however I am not sure that this is my problem.  I
: can not even get the module to load - as I mentioned, the script parse
: errors when trying to load the module.  I haven't even gotten it to
: "compile" when I try to "use Win32::AdminMisc", but when I # that out
: the script runs fine...

Are you sure that Win95 has maintained the correct case for the
module; i.e. - AdminMisc might now be called adminmi~1, where Perl
might be unhappy about it.  :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Sat, 05 Apr 1997 01:24:24 GMT
From: twtmjctn@superlink.net (Kevin Murphy)
Subject: Help with Associative Array
Message-Id: <5i4775$5if$1@earth.superlink.net>

Hello, 
I have been given an assignment at work and need some help.
I am trying to read some data from a file that looks like this:
  Northing    Easting   Elev. Name
 143683.940 325574.285  0.157 1001,ST TB 1+00
 143681.492 325575.371 -2.887 1002,BB 1+00
 143661.554 325583.451 -6.014 1003,CL 1+00
 143634.828 325597.329 -2.077 1004,BB 1+00
 143631.621 325596.991  0.335 1005,END TB 1+00
then I want to calculate a distance from the point CL
to each of the remaining points, the ones before CL in the list would 
get a negative number, the ones after the list would be positive.

I can handle the splits and calculations, but I am at a loss on how to
read the data into an array that I can get to after I have reached the
END text.
I think I should use a subroutine to do the calc's once i have
determined the ST and END elements in the array.
       $infilename = shift(@ARGV);# $ARGV[0]
       $outfilename = shift(@ARGV);# $ARGV[1]
open (IN,$infilename) ||
        die "Cannot open $infilename for reading";
## optional test for overwrite
die "will not overwrite $outfilename" if -e $outfilename;
open (OUT,">$outfilename") || die "cannot create $outfilename";
while (<IN>)  {
    chop;                       #
    @fields=split(/,/);       #
        $a = $fields[0];
        $b = $fields[1];
        @nez=split(/ /,$a);
        $northing=$nez[0]
        $easting=$nez[1]
        $elevation=$nez[2]
        $name=$nez[3]
        @codes=split(/ /,$b);
        $codes1 = $codes[0];
        $codes2 = $codes[1];
        $codes3 = $codes[2];
#                print OUT "$a\n"
#not sure what to put here
                }
}
close (IN);
close (OUT);

I need to be able to get the nortning & easting for each point and add
calculate
the distance between it and the CL point.

I will be working on this one all weekend
Any ideas would be greatly appreciated.
thanks
kevin




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

Date: 4 Apr 97 21:28:12 GMT
From: "Jerry Bradenbaugh" <bradenb@ibm.net>
Subject: How Do I...
Message-Id: <01bc413f$bbb86420$adc32581@jkb>

How do I access the user name and password fields from the dialog box
prompted by restricting access to files or directories on a UNIX platform?

I want to use the information as variables in another CGI Script.

Regards,


Jerry Bradenbaugh


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

Date: 4 Apr 1997 20:28:38 GMT
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: How to extract string starting with n characters?
Message-Id: <5i3o9m$8hq@gcsin3.geccs.gecm.com>

dblack@icarus.shu.edu (David Alan Black) wrote:

>Welcome to the world of regular expressions.  
>
>	$record = "Lyndon Johnson was from Texas";
>	($johnpart) = $record =~ /(John\w+)/; 
>
>or (John\w+ ) if you want the space to be part of the return string.

Thank you.

$MyLine="The Johnstones live in Johnson City with their dog JohnBoy";
($johnpart) = $MyLine =~ /(John\w+)/;

# Thanks to a private response which helped me extract multiple
# occurrences in a line into an array:

(@johnpart) = $MyLine =~ /(John\w+)/g;

>
>Pointers to references are another matter :-)

That's bad.

>
>But do buy/read:
>
>Programming Perl
>Mastering Regular Expressions   <--- everybody - buy this.

That's good. Thanks again.

Cheers,

Jim



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

Date: Fri, 4 Apr 1997 20:50:20 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: How to get key from value in a %VAR
Message-Id: <E84sJw.Axo@cix.compulink.co.uk>

basj@xs1.xs4all.nl (basj) wrote:

> I need to get the key that belongs to a value in a %VAR. How do I do 
> that ? I can get the value if I have a key but I need to do the reverse 
> lookup.

The hard way:

$key = "Something wrong, didn't find it";
foreach $k( keys( %VAR))
{
        if( $VAR{$k} == $value)
        {
                $key = $k;
                last;
        }
}

The easy way:

If you need to do reverse lookup a lot, make the hash array twice, one 
keyed on the "key" values and one keyed on the "data" values.

John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked: 
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, Perl for 
NT/Win 95 can be found at http://www.activeware.com, with an excellent 
FAQ file at 
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html and no, 
I don't have the slightest idea what's wrong with your CGI script. Try 
http://www.perl.com/perl/faq/idiots-guide.html


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

Date: Fri, 4 Apr 1997 16:47:14 -0800
From: Tom Phoenix <rootbeer@teleport.com>, Tom Phoenix <rootbeer@teleport.com>
To: Douglas Seay <seay@absyss.fr>
Subject: Re: How to get key from value in a %VAR
Message-Id: <Pine.GSO.3.96.970404164532.21773D-100000@kelly.teleport.com>

[ Oops. A second try, with the proper punctuation this time! ]

On Fri, 4 Apr 1997, Douglas Seay wrote:

> basj wrote:
> > 
> > I need to get the key that belongs to a value in a %VAR. 
> > How do I do that ? I can get the value if I have a key but 
> > I need to do the reverse lookup.
> 
> use each() and check each key/value pair.
> note that values are not necessarily unique,
> so be prepared for multiple matches.

Or, if you have to do this multiple times, invert the hash.

    %IVAR = reverse %VAR;
    $key = $IVAR{$value};

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 04 Apr 1997 16:02:53 -0500
From: CNT82784 <nrstrc9@nortel.ca>
Subject: Netscape and File Upload
Message-Id: <33456C7D.150E@nortel.ca>

Is it possible to send multiples files using the File Upload feature 
from netscape?


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

Date: Fri, 04 Apr 1997 21:58:36 +0100
From: Alasdair Thomson <alasdairt@private.nethead.co.uk>
Subject: Re: New Microsoft Perl Product (fwd)
Message-Id: <33456B7C.3021@private.nethead.co.uk>

Eric Bohlman wrote:
> 
> Paddy Spencer (paddy.spencer@parallax.co.uk) wrote:
> 
> : Obj(Newbie)Perl:
> 
> : I know you can do this:
> 
> :       $arg eq "-n" || die "Use -n you moron!!\n";
> 
> : and if you try doing
> 
> :       $arg eq "-n" || $arg = "-n";
> 
> : it complains about modifying logical or operator. Any way around this
> : or does one have to use the incredibly passe if(...){} construct?
> 

I'm sorry, but I am the only harrased person who has to understand
scripts written by lots of developers who *thought* they were the best
by choosing the shortest, least user friendly code  . . . 

While I understand *completely* the issues involved I would still like
to see programmers put READABILITY above most other issues, at least
comment yout bloody code.

I'm sorry, but the use of the "incredibly passe" if (...){} construct at
least makes it obvious what it's attempting to do, and ensures that LESS
MISTAKES happen during coding.

Perhaps that's the difference between people that muck around with
languages at college and people who's jobs depend upon them.


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

Date: Sat, 05 Apr 1997 01:16:51 +0100
From: Donald Syme <drs1004@cl.cam.ac.uk>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <334599F3.1079@cl.cam.ac.uk>

Chris Bitmead wrote:
> 
> chen@adi.COM (Franklin Chen) writes:
> 
> >To see the advantages of a typeless language, consider the following
> >Tcl command:
> >
> >button .b -text Hello! -font {Times 16} -command {puts hello}
> >
> >This command creates a new button control that displays a text string
> >in a 16-point Times font and prints a short message when the user
> >clicks on the control. It mixes six different types of things in a
> >single statement: a command name (button), a button control (.b),
> >property names (-text, -foreground, and -command), simple strings
> >(Hello! and hello), a font name (Times 16) that includes a typeface
> >name (Times) and a size in points (16), and a Tcl script (puts
> >hello). Tcl represents all of these things uniformly with strings. In
> >the button example the properties may be specified in any order and
> >unspecified properties are given default values; more than 20
> >properties were left unspecified in the example.
> >
> >The button example requires about 25 lines of code in three procedures
> >when implemented in C++ with Microsoft Foundation Classes. Just
> >setting the font requires 7 lines of code:
> >
> >LOGFONT lf;
> >
> >memset(&lf, 0, sizeof(lf));
> >
> >lf.lfHeight = -16;
> >
> >strcpy(lf.lfFaceName, "Times New Roman");
> >
> >CFont *fontPtr = new CFont();
> >
> >fontPtr->CreateFontIndirect(&lf);
> >
> >buttonPtr->SetFont(fontPtr);
> 
> Come on! All this shows is the inconveniece of using the MFC
> classes. An interface exactly the same as the Tcl one could easily be
> written in C++.
> 

Trash.  Show me C++ which is as succinct and I may believe you.  

For example the O'Caml crowd (who I think are wonderful)
have to bend over backward to create O'Labl (again wonderful)
to achieve anything like the succinctness Ousterhout achieves
in Tcl/Tk, precisely because of the ML type system.  Ousterhout
is right on this point at least: strong, static typing
does often mean cutting back on nifty syntactic tricks that
are played with untyped languages (like specifying a font
with just "Times 16", or allowing config parameters in any order).
At least until the language designers
add some features (like labelled optional arguments) to their
language.

Don 

P.S. I think I must be the only person in the world who
is a Tk/Tcl fan *and* an ML/Scheme/Java fan.  Different
horses for different courses!


-----------------------------------------------------------------------------
At the lab:                                          At home:
The Computer Laboratory                              Trinity Hall
New Museums Site                                     CB2 1TJ
University of Cambridge                              Cambridge, UK
CB2 3QG, Cambridge, UK
Ph: +44 (0) 1223 334688                              Ph: +44 (0) 1223
505863
http://www.cl.cam.ac.uk/users/drs1004/
email: drs1004@cl.cam.ac.uk
-----------------------------------------------------------------------------


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

Date: 4 Apr 1997 13:38:34 -0800
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: Perl and permissions
Message-Id: <5i3scq$8vf@shell3.ba.best.com>

In article <334559C9.74AB@garnet.acns.fsu.edu>,
=?iso-8859-1?Q?ANSEK=AE?=  <kll8927@garnet.acns.fsu.edu> wrote:
>Is it possible to and a sting to a perl script that will execute a chmod
>command so that the newly generate files by the script will be given a
>specified set of permissions. My sever does not give read permisions to

Perl has two functions which may be of use to you in solving this problem.
The documentation for both of them is in the perlfunc man page. Look at
umask() and chmod().

/MC
-- 
--
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@taos.com (work)     | time you make it.


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

Date: Fri, 04 Apr 1997 18:13:56 -0400
From: Rob de Roos <rd19@cornell.edu>
Subject: re: Perl listserve?
Message-Id: <33457D0B.6B20@cornell.edu>

Is there an e-mail list discussion group for Perl?

	If there is a mailing list also, let me know.


************************************************************
   Rob de Roos
   rd19@cornell.edu


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

Date: 04 Apr 1997 20:20:09 GMT
From: ceh@tiros.sce.carleton.ca (Curtis Hrischuk)
Subject: PROBLEM:  Can't call method "import" in empty package <file>
Message-Id: <CEH.97Apr4152009@tiros.sce.carleton.ca>

Hi.  Perl 5.001 is reporting that it can't call the method "import" in
the package "trace" from a source file.  

In the source file I have the statement "use trace;".

The file "trace.pm" exists and is located in the directory
'/home/ceh/ObjecTime/xa'.

Before the 'use' statement I have inserted an 'push(@INC,
'/home/ceh/ObjecTime/xa');'.

What is the problem?

The actual code is here:

	push(@INC, '/home/ceh/ObjecTime/xa');
	require 'assert.pl';
	require 'mystd.pl';
	require 5.001;
	use Getopt::Long;
	use trace;
	use thread;
	use event;
	use apptime; 
	use diagnostics;
	use strict "refs";
	
	
Curtis
-- 
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Curtis Hrischuk (PhD Cand)  "in reality that comes from above      _/
_/ ceh@sce.carleton.ca          God is calling                        _/
_/ Carleton University          there's no bigger love                _/
_/ Ottawa, On., Canada, K1S-5B6 It's his reality that welcomes us back_/
_/ Ph  (613) 520-2600 x1762     Trust and obey                        _/
_/ FAX (613) 520-5727           there is no other way..." the newsboys_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


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

Date: Fri, 4 Apr 1997 13:40:15 -0600
From: Greg Lewis <lewis@dnai.com>
Subject: Re: Simple array question by newbie...
Message-Id: <Pine.LNX.3.91.970404125951.4240A-100000@dagmar.greg.lewis>



On 3 Apr 1997 13:28:10 GMT, alweiner@clark.net (Alan Weiner) wrote:
 
>I've written a simple subroutine which inputs a month and returns the 
>next month.  However, it doesn't seem to work :)  
>
>1) Is there a better way to do this?
>2) What am I doing wrong?
>
>Here's what I've got:
>
>
>@months=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","No
>v","Dec","Jan");
>
>$nxtMonth=getNxtMonth("Mar");
>print "$nxtMonth";
>
>sub getNxtMonth {
>local($thisMonth)=@_;
>foreach (@months) {
>    if($thisMonth == $_) {
>            return ($months[$#months+1]);
>            }
>    }
>}
>
>Thanx for any help you can provide!  Pls post the answer here...
>


You seems to have made three or four mistakes:

1 using numeric comparison string comparison i.e == instead of eq 
2 $months[$#months+1] is undefined, it is one past the last element of
  the array.
3. subroutines take lists. local($thisMonth)=$_; cuases an error.
   use:  local($thisMonth)=$_[0];
4. my guess is that you are not using the -w option! it finds errors use it!

The following works:

#!/usr/bin/perl -w

@months =  ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct", 
"Nov","Dec","Jan" );

$nxtMonth=&getNxtMonth( 'Apr' );
print "$nxtMonth\n";

sub  getNxtMonth {
  local($thisMonth)=$_[0];
  for ($i=0;$i<$#months;$i++) {
     if ($thisMonth eq $months[$i]) { 
       return ($months[$i+1]);
     }
  }
i}


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

Date: 04 Apr 1997 16:15:56 -0500
From: Clark Dorman <dorman@s3i.com.anti-spam>
Subject: Re: Starting, Suspending, and Restarting a Child
Message-Id: <dk9mitroz.fsf@s3i.com>


Tom Christiansen <tchrist@mox.perl.com> writes:
> In comp.lang.perl.misc, 
>     armin.faltl@siemens.at writes:
> :	kill $SIGSTOP $pid if $chldActive;
> 
> You mean 
> 
>     kill 'STOP', $pid if $child_active;
> 
> Note especially the comma.

Much thanks to you and Armin.  I have attached a copy of the program that I'm
presently working with, which does what Armin suggested.  

I am not sure what the difference is between using 'STOP' and $SIGSTOP after
$SIGSTOP is set to the proper value.  I need $SIGSTOP = 23 and $SIGCONT = 25.
How would I know that STOP is $SIGSTOP?  I looked under perlvar and perlipc,
and they make references to the various signals, but not a list and what they
mean.  signal(5) has some info (and that's where I got the above number) and
doing a kill -l lists them, but I cannot find more information.  Where do I
look?  The following code provides some answers (and confirms that 23 and 25
are STOP and CONT) but I'm not sure what all these do:

----------------------------------------------------------------------
#!/home/dorman/bin/perl -w

use Config;
defined $Config{sig_name} or die "no sigs";

$i = 0;
foreach $name (split (' ', $Config{sig_name})) {
   $signo{$name} = $i;
   $signame[$i]  = $name;
   $i++;
}

for ( $j=0; $j< $i;  $j++) {
   printf "%20s  %3d \n", $signame[$j], $signo{$signame[$j]};
}
----------------------------------------------------------------------

One problem I am now having is that the child leaves (finishes up with the
processing) and the parent sticks around indefinitely.  I need the child to
clean itself up somehow.  In the parent, I tried to do:

1.  	$gottenPgrp = getpgrp $pid; 
	exit(0) if ($gotenPgrp == 0);

where $pid is the id of the child.  However, it won't let me do getpgrp on a
$pid under POSIX.  

2.    $kill_response = kill 0, $pid;
      print " kill 0 response ($kill_response)\n"

The problem is that the pid sticks around forever, with a little <defunct>
next to it.

3.  $SIG{CHLD} = \&child_done;

    ...[program here]

    sub child_done {
       print "Got a CHLD signal \n";
    exit(0);
    }

This is supposed to exit when the child is done since the parent (I think)
gets a CHLD signal when the child is done.  However, the parent gets CHLD
signals a lot, not just when it ends; specifically every time you start and
stop the child, you get a signal.

Does Perl produce something like that produced by siginfo (see man -s5
siginfo) where there is a structure that is more explicit about what happened
(so I can tell an exit from a stop and continue)?

4.    $psResponse =  `/usr/bin/ps -p $pid -o pid=` or die 
	"cannot do a ps on the process ($!)";
      chop( $psResponse );
      print " ps response is ($psResponse) \n";
      exit(0) if ($psResponse != $pid);

This ps is supposed to return the pid if it exists, and nothing if not.  This
does not work for the same reason as #2.

5.  This works, but is rather ungraceful so I do not like it:
     $psResponse =  `/usr/bin/ps -p $pid` or die 
	"cannot do a ps on the process ($!)";
      print " ps response is ($psResponse) \n";
      exit(0) if ($psResponse =~ /defunct/);

Clark

----------------------------------------------------------------------
#!/home/dorman/bin/perl -w

$pid  = fork;

# $SIGSTOP = 23;
# $SIGCONT = 25;
# $SIG{CHLD} = \&child_done;      # This doesn't work. 

$my_hostname = `hostname` or die "Cannot find hostname ($!)";

# Just for testing, gives lots of starts and stops.
$load_limit = 0.5;

######################################################################
# parent
if ($pid > 0) {
   print " In the parent, pid of child is $pid \n";
   $childRunning = 1;
   $childActive  = 1;
   while ($childRunning ) {
      
      ############################################################
      # check load
      $rup_response = `rup $my_hostname 2>&1` ;
      @x = split( ' ', $rup_response ) ;
      if ( $rup_response =~ /average:\s(\d+.\d+),/ ) {
	 $load_level = $1;
      } else {
	 die "Something wrong with rup_response ($rup_response)";
      }
      
      ############################################################
      # stop if load level too high and it's active
      if ($load_level > $load_limit and $childActive) {
	 print " stopping the child ($load_level)\n";
	 # kill $SIGSTOP, $pid
	 kill 'STOP', $pid;
	 $childActive = 0;
      } 
      if ($load_level < $load_limit and ! ($childActive) ) {
	 print " restarting the child ($load_level)\n";
	 # kill $SIGCONT, $pid
	 kill 'CONT', $pid;
	 $childActive = 1;
      }
      
      ############################################################
      # wait a while before checking again
      sleep 5;

      ############################################################
      # This does not work under POSIX
      # $gottenPgrp = getpgrp $pid; 

      ############################################################
      # This does not work because the $pid sticks around <defunct>
      # $psResponse =  `/usr/bin/ps -p $pid -o pid=` or die 
      # "cannot do a ps on the process ($!)";
      # chop( $psResponse );
      # print " ps response is ($psResponse) \n";
      # exit(0) if ($psResponse != $pid);

      ############################################################
      # This does not work because the child sticks around.  
      # $kill_response = kill 0, $pid;
      # print " kill 0 response ($kill_response)\n";

      ############################################################
      # This works but is very ugly
      $psResponse =  `/usr/bin/ps -p $pid` or die 
	"cannot do a ps on the process ($!)";
      print " ps response is ($psResponse) \n";
      exit(0) if ($psResponse =~ /defunct/);
   }		
} 
elsif ($pid == 0) {
   # we're the child
   print " In the child \n";
   &do_the_work();
   print " child done, exiting ------------------------------\n";
   $childRunning = 0;
   exit(0);
} 
else {
   # fork failed
   die "child process failed \n";
}

######################################################################
# Should come here when we get a CHLD signal
# Does not work because we get lots of CHLD signals.
sub child_done {
   print "Got a CHLD signal \n";
   exit(0);
}

######################################################################
# This will take about 100 seconds on blackbird
sub do_the_work {
   for ($j=0; $j < 1000; $j++) {
      for ($i=1; $i<= 1e15; $i *= 7) {
	 $result = &commas( $i );
	 $result = $result . "compilerbait";
	 #	 printf " %30s \n", $result;
      }
   }
}

sub commas {
   local( $_) = @_;
   1 while s/(.*\d)(\d\d\d)/$1,$2/;
   $_;
}




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

Date: 4 Apr 1997 23:18:14 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: string comparision
Message-Id: <5i427m$jia$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Vladimir Alexiev 
<vladimir@cs.ualberta.ca>],
who wrote in article <omn2re5xlf.fsf@tees.cs.ualberta.ca>:
> In article <334422BB.429DF349@enteract.com> Eryq <eryq@enteract.com> writes:
> 
> > If you meant "strings of unsigned bytes"... then 'eq' works fine.
> 
> I think he means cmp, not eq. The answer is, you can't unless you install a
> locale that provides appropriate collating functions. cmp invokes strcmp
> (correct me if I'm wrong) which uses char which actually means signed char.
>    $ perl -e 'print "\x80" cmp "\x7F", "\n";'
>    -1

Upgrade.  This particular bug in (Solaris?) CRT was discovered only
recently, so perls starting from 5.003_16 (or around) check for it
before the build.

Ilya


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

Date: 5 Apr 1997 00:05:58 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: symbolic reference doesn't work with arrays?
Message-Id: <5i4516$2hr@pirate.shu.edu>

Hello -

Brett Denner <Brett.W.Denner@lmtas.lmco.com> writes:

>I am trying to use a symbolic reference to change array elements
>as follows:

>  my @one = ('a');
>     @two = ('b'); # <============ Note: no "my"

>  print "before: $one[0], $two[0]\n";

>  $name     = "one";
>  $$name[0] = 'A';

>  $name     = "two";
>  $$name[0] = 'B';

>  print "after:  $one[0], $two[0]\n";

>In perl 5.003, on IRIX 6.2, this prints out:

>  before: a, b
>  after:  a, B

>The second line should be "after:  A, B".

>Why should declaring the @one array with "my" prevent the symbolic 
>reference from working properly?  Is this a bug, or am I using the 
>"my" declaration or the symbolic reference improperly?

See Camel, pp. 254-255: "Only package variables are visible to
symbolic references.  Lexical variables (declared with my) aren't
in a package symbol table, and thus are invisible to this mechanism."

David Black
dblack@icarus.shu.edu



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

Date: Fri, 04 Apr 1997 16:11:51 -0500
From: Liyun Wang <Liyun.Wang.1@gsfc.nasa.gov>
Subject: VMS Perl question
Message-Id: <33456E97.41C6@gsfc.nasa.gov>

Hi,

I write perl scripts to be run under VMS. I have a routine that uses
system call to convert *all* logical names into %ENV: 

sub preload_env {
    foreach (`sho log`) {
        chop;
#        next unless /\"([^\"]+)\"\ \=\ \"+([^\"]+)\"+/; # cause problem
1
#        next unless /\"(\w+)\"\ \=\ \"+([^\"]+)\"+/;    # cause problem
2
        next unless /\"(\w+)\"\ \=\ \"+(\w+)\"+/;        # no problem
        $ENV{$1} = $2;
    }
}

Notice I have commented out two lines that can cause problems. The line
that says "cause problem 1" would grab all logicals whose names and
values can contain any characters (except double quote), including those
special ones such as dollar sign ($), colon (:), and square bracket
([]). If the routine is called with this line enabled, I get a strange
problem: some of system device names are changed. For example,
SUMOP1$DRA0:[SYS0.SYSCOMMON.SYSEXE] is changed to
SUMOP1$DRA0:[SYS0.][SYSEXE]. Because of that, the OS no longer can find
any executable (images), including dir, show, or even help.

The line that says "cause problem 2" would grab only those logicals
whose names contain only alphanumeric characters. After calling the
routine, I didn't have the above problem, but my current directory is
changed, for example, from UDISK:[LWANG.PERL] to
SUMOP1$DRA1:[WORKSHOP.][LWANG.PERL] (UDISK is a concealed device defined
as SUMOP1$DRA1:[WORKSHOP.]). 

It seems I can only grab logicals whose names and values do not contain
any special characters without any problem, with the line marked as "no
problem". 

I understand that some of our device names are defined as concealed
device.

My question is: What happened when either commented line was executed
and why?

The Perl package we are running is a precompiled one. To show you my
perl environment, here is what's returned when it is run with the -v
flag:

> This is perl, version 5.003 with DEBUGGING EMBED
>         built under VMS at Feb  1 1997 16:08:36
>         + suidperl security patch
> 
> Copyright 1987-1996, Larry Wall
> 
> Perl may be copied only under the terms of either the Artistic License or the
> GNU General Public License, which may be found in the Perl 5.0 source kit.

I appreciate any help of yours.

Thanks,

Liyun

-- 
==================================================================
Liyun Wang                |                      FAX: 301-286-0264
G1 Building 26, SOHO EAF  |                    Voice: 301-286-3126     
NASA, GSFC, Code 682.3    |             Liyun.Wang.1@gsfc.nasa.gov
Greenbelt, MD 20771       |  http://orpheus.nascom.nasa.gov/~lwang
==================================================================


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

Date: Fri, 4 Apr 1997 20:50:22 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: Wildcards for a list of filenames
Message-Id: <E84sJz.Ayn@cix.compulink.co.uk>

jhamlin@ai.uga.edu (Jon Hamlin) wrote:

> I have a pattern for filenames (say, *.bak) which is user specified (so
> it's not hard coded into the Perl code).  Is there a way to take this 
and
> get a list of files that match that pattern using readdir and grep?  I'm
> at a loss since the regular expressions in Perl wouldn't really see 
*.bak
> the same way the shell would -- Perl would really want .*bak or 
> something similar, right?

Given the directory in $dir, and the pattern in $patt, here are two ways:

a) Use the filename glob operator, rather than readdir:

   @files = <"$dir/$patt">;

b) Write a subroutine to convert the pattern: here's an untested off-the 
cuff version of one:

   sub OSwildcard2regexp
   {
   local( $regexp) = @_;
   $regexp =~ s/\./\\\./g;      # escape the dots in the pattern
   $regexp =~ s/\*/\.\*/g;      # convert * to .*
   $regexp =~ s/\?/\./g;        # convert ? to .   
   }


John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked: 
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, Perl for 
NT/Win 95 can be found at http://www.activeware.com, with an excellent 
FAQ file at 
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html and no, 
I don't have the slightest idea what's wrong with your CGI script. Try 
http://www.perl.com/perl/faq/idiots-guide.html


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

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

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