[8801] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2418 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 25 17:07:26 1998

Date: Sat, 25 Apr 98 14:00:28 -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           Sat, 25 Apr 1998     Volume: 8 Number: 2418

Today's topics:
    Re: $100 - PERL NEWSGROUP POSTER lvirden@cas.org
    Re: ask people to wait <news@alameh.net>
        Bye All :-) <bill@astro.fccj.cc.fl.us>
    Re: Bye All :-) (Jonathan Stowe)
        can ne, not equal, ne? <scott@rappahannock-web.com>
    Re: can ne, not equal, ne? <jdf@pobox.com>
    Re: can ne, not equal, ne? (Jonathan Stowe)
    Re: Defending Perl <Tim.Writer@ftlsol.com>
    Re: getting the last element position in multi dimentio <rjk@coos.dartmouth.edu>
    Re: how to change password in netscape webserver with a ender@mythen.ch
    Re: How to turn off warnings at *compile time*? (M.J.T. Guy)
    Re: ls -R ? (Jonathan Stowe)
    Re: ls -R ? <ljz@asfast.com>
    Re: matching man page lines <rjk@coos.dartmouth.edu>
        newbie question <itovsto@emory.edu>
    Re: newbie question <daniel@nospamstridhammar.pp.se>
    Re: PERL chmod on NT (Jonathan Stowe)
    Re: Perln for NT (Jim Weisgram)
    Re: Please stop and help. (Jim Michael)
    Re: Please stop and help. <mhanson@wyoming.com>
    Re: Problems with 'wait' under perl5.004 (M.J.T. Guy)
    Re: Problems with 'wait' under perl5.004 (Jason Gloudon)
        recursive file permission changes? (David Askov)
    Re: recursive file permission changes? (Jim Michael)
    Re: recursive file permission changes? (Jonathan Stowe)
    Re: Setting $AUTOLOAD when calling SUPER::AUTOLOAD? (M.J.T. Guy)
        Strange Behavior Of "gethostbyaddr" <Rodney.Wines@ahqps.alcatel.fr>
    Re: System call in Perl not working <rjk@coos.dartmouth.edu>
    Re: System call in Perl not working <rjk@coos.dartmouth.edu>
    Re: Using module outside @INC without changing @INC (M.J.T. Guy)
        Why doesn't this work? <smoothie@spiritone.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 25 Apr 1998 17:10:18 GMT
From: lvirden@cas.org
Subject: Re: $100 - PERL NEWSGROUP POSTER
Message-Id: <6ht5dq$koo$1@srv38s4u.cas.org>


According to Alexander Kovalenko  <luckycom@ica.net>:
:willing to pay for program which would work like formmail , but not send
:e-mail , but rather post it to newsgroups..
:
:if you can help me... reply back...
:

You want to pay a hundred bucks for a program to fill newsgroups up
with form letters?

I suspect someone would come up with a couple hundred to stop you...
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Sat, 25 Apr 1998 17:49:04 +0300
From: "Issam Alameh" <news@alameh.net>
Subject: Re: ask people to wait
Message-Id: <6hu5ct$fgg@ns1.qatar.net.qa>

Well if I am you i'll do the following:
in deffirent stages of my program i'll save some useful data to a file, and
i'll do another script which will handle translation of this data to
something the user can understand from it, in which stage your program is,
then at the client you use client pull ( I think they call it this way) what
actually u do is use the refresh meta tag, it is some thing like this:
<meta http-equiv=refresh
content=RefreshRate;url=http://yoursite/yourcgi.cgi>
if your server Supports SSI that will be great, and this way each
RefreshRate seconds they guy will know where is your program and what it is
doing,
well I hope such an idea will be of help to you,
Regards
Issam Alameh
http://www.alameh.net

Sleep wrote in message <6hk9j9$h1n@eng-ser1.erg.cuhk.edu.hk>...
>   Hail !
>   I am writing a CGI(Perl of course :) programme that will verify
>a user and then do a search in another server. The problem is that
>Internet always has traffic congession. And the search may take up to few
>mins which, I believe, will confuse the user that the machine is hang !
>   So I want to prompt a messag when the user suceed in the verification
> but searching hasn't finish. I've try the "server push" technique to
>show the user a page of "warning" and it work fine, but unlucky it's a
>Netscape "product" & so M$ doesn't "like" it  :(
>   As I am not Bill that I can't choose the broswer for the reader. my
>question is:   Any other "universal" method can do the same thing ?
>
>
>   Thanx for attention.
>
>Regards,
>Chau.
>
>PS. I don't know which newgroup should I post. So please forward this post
>to a more appropraite one if u think it is :P




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

Date: Sat, 25 Apr 1998 15:48:50 GMT
From: Bill 'Sneex' Jones <bill@astro.fccj.cc.fl.us>
Subject: Bye All :-)
Message-Id: <3542043C.E5CB08B4@astro.fccj.cc.fl.us>

I just wanted to say I have enjoyed hangin' out here
and reading everyones queries and other's answers or flames :-)

I will miss you! :-)

C'Ya, and take care!
Sneex
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 904-632-3089 | Fax 904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.cc.fl.us | http://www.fccj.cc.fl.us


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

Date: Sat, 25 Apr 1998 01:02:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Bye All :-)
Message-Id: <354134d5.84229300@news.btinternet.com>

On Sat, 25 Apr 1998 15:48:50 GMT, Bill 'Sneex' Jones
<bill@astro.fccj.cc.fl.us> wrote:

>I just wanted to say I have enjoyed hangin' out here
>and reading everyones queries and other's answers or flames :-)
>
>I will miss you! :-)
>
You got us all intrigued now.  Whats going on:  you going to the
chair, they banned usenet in Florida, you're going back to your home
planet, what ?

/j\ 
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Sat, 25 Apr 1998 14:03:14 +0000
From: scott <scott@rappahannock-web.com>
Subject: can ne, not equal, ne?
Message-Id: <3541ECF7.33FEAFC8@rappahannock-web.com>

please someone tell me if i am missing something here.

the script checks a log for a date, if the date does not match the current
date it deletes old records from a database.

-------------------------------
$the_current_year = `date +"%Y"`;
        chop($the_current_year);
$datem = `date +"%m"`;
        chop($datem);
$dated = `date +"%d"`;
        chop($dated);
        
$plog_str = "$the_current_year$datem$dated";

&CheckPlog;

#        check the log to see if database might need
#        pruning

sub CheckPlog
{        
open (PLOG, ">$prune_log");
while (<PLOG>){$plog_date = "$_";}

if ($plog_date ne $plog_str){&Prune}
    
    print  PLOG "$plog_str";
    close (PLOG);
   }#      end CheckPlog

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

the if statement comes out true every time even after running the script over
again. it seems to me that it could only be true once in a day. $plog_str is
used many times throughout the script, yeilding the correct date. what could
cause the value of $plog_date to not match.

any comments are appreciated.
-- 
thanks,
scott prince


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

Date: 25 Apr 1998 16:16:01 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: can ne, not equal, ne?
Message-Id: <u37hmwku.fsf@mailhost.panix.com>

scott <scott@rappahannock-web.com> writes:

> $the_current_year = `date +"%Y"`;
>         chop($the_current_year);

I'd recommend chomp over chop, and you can be pithier with this idiom:

   chomp($foo = `some command`);

> open (PLOG, ">$prune_log");
> while (<PLOG>){$plog_date = "$_";}

Oops.  You're opening a file for writing (*and* not checking the
success of the open call), then trying to read from it.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Sat, 25 Apr 1998 03:44:45 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: can ne, not equal, ne?
Message-Id: <354159f4.92206332@news.btinternet.com>

On Sat, 25 Apr 1998 14:03:14 +0000, scott wrote :

<snip>
>
>-------------------------------
>$the_current_year = `date +"%Y"`;
>        chop($the_current_year);
>$datem = `date +"%m"`;
>        chop($datem);
>$dated = `date +"%d"`;
>        chop($dated);
>        
>$plog_str = "$the_current_year$datem$dated";
>

It might seem picky but I really dont think you want to be calling the
external command there.  You might want to use the Date::Format module
available from CPAN.  e.g.

use Date::Format;

$plog_str = time2str("%Y%m%d",time);


/J\
Jonathan Stowe
Some of your questions answered http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 25 Apr 1998 12:59:19 -0400
From: Tim Writer <Tim.Writer@ftlsol.com>
Subject: Re: Defending Perl
Message-Id: <m3emyl96s8.fsf@snoopy.ftlsol.com>

John Goerzen <jgoerzen@southwind.net> writes:

> wayne@Glue.umd.edu (Wayne C. McCullough) writes:
> 
> > Hard to install?  I don't know.  I have only installed it on a win-95
> > machine.  There it was more difficult to install than most aplications,
> > but it didn't take me more than 20 minutes to do.  
> > 
> > On a UNIX box, I suspect it all depends on how savy you are.  I have had
> > some problems installing Tk on unix boxes, but that is probably my own
> > stupidity.  I suspect someone with a little bit of experience and a lot
> > of willingness to read all the help files could install Perl on most
> > UNIX machines fairly easily.
> 
> I might point out that many of the most popular Unix operating systems 
> -- including FreeBSD, Debian GNU/Linux, RedHat, and BSDi -- come with
> Perl either preinstalled or with a Perl package that can be installed
> in 3 minutes or less.

There's also a Solaris package at the Solaris freeware site (smc.vnet.net).

-- 
Tim Writer                                              Tim.Writer@ftlsol.com
FTL Solutions Inc.
Toronto, Ontario, CANADA


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

Date: Sat, 25 Apr 1998 12:37:55 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: getting the last element position in multi dimentional array
Message-Id: <35421164.D762AEA4@coos.dartmouth.edu>

jong wrote:
> 
> But I want to know the highest number of each
> dimension. So, I want to know
> 
> what $array[x]
> what $array[x][y]
> what $array[x][y][z]
> 
> in their highest values.
> 
> If the last array element was:
> 
> $array[3][3][9]
> 
> I'like to know how to get the 3, 3, 9

$#array
$#{$array[$#array]}
$#{$array[$#array][$#{$array[$#array]}]}

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 25 Apr 1998 15:05:04 GMT
From: ender@mythen.ch
Subject: Re: how to change password in netscape webserver with a CGI?
Message-Id: <3541fb72.4925923@news.unisource.ch>

On Tue, 21 Apr 1998 09:47:12 GMT, Bill 'Sneex' Jones
<sneaker@earthling.net> wrote:

>> We have many users defined in a Netscape Enterprise Server 2.0
>> Database. Now the maintenance takes a lot of time and only the server
>> administrator can change user data.

>Netscape.  At Netscape's home site, research this and you may find that
>either upgrading to NSE3.0 or possibly using another WWW server
>may more advantagous.  I resolved the problem by using the
>/etc/passwdfile as my user database and then using the WebPass
>system to manage passwds, etc...

Hi Bill

Many thanks for your comprehensive response.
I found a small command-line program wich is able to change the
password. Now it should be easy to implement it with CGI.

best regards 

Josi




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

Date: 25 Apr 1998 15:22:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: How to turn off warnings at *compile time*?
Message-Id: <6hsv3r$nvc$1@lyra.csx.cam.ac.uk>

Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
>
>I'll say
>
>	BEGIN {
>	  local $^W = 0;
>	  use FindBin;
>	}
>
>" No such luck.  As the FAQ says, $^W controls run-time warning printing.
>And of course this is compile-time.

There's never any point in putting a "use" within a BEGIN block, as "use"
is already done at compile time; in particular, it'll be done before the
BEGIN {} block is run and $^W set to 0.

>So how could I control compile-time warning printing?

By setting $^W at compile time, by putting the assignment in a BEGIN
block:

       BEGIN { $^W = 0 }
       use FindBin;
       BEGIN { $^W = 1 }


Mike Guy


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

Date: Fri, 24 Apr 1998 22:39:48 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: ls -R ?
Message-Id: <354105d3.74684488@news.btinternet.com>

On 25 Apr 1998 12:21:14 GMT, jon@blading.com wrote:

>hello
>i read through the recent thread concerning ways to pring the contents of
>a dir (most settled on readdir() opendir() etc).
>is there a way to readdir() recursively?  i could find no mention in the
>online docs for readdir() and unfortunately don't have my camel book close
>at hand.
>
<etc>

You probably want to use File::Find to do this.  It will protect you
from the exigencies of your filesystem.

Of course you can do this yourself if you must.  The neatest way to do
this would be with the DirHandle module which will overcome the
nastiness you will encounter with caching Directory handle globs.

A quick example would be:

#!/develop/bin/perl

use DirHandle;

dodir("/htdoc");

sub dodir()
{
   local $dir = shift;

   my $dirhandle = new DirHandle($dir);

   if($dirhandle)
     {
      while($file = $dirhandle->read)
        {
          next if ($file =~ /^\.{1,2}$/);
          my $fullpath = $dir . "/" . $file;
       
          if (-d $fullpath)
            {
             dodir($fullpath);
            }
          else
             { 
              print $fullpath,"\n";
             }
         }
     }
}
__END__

To see why you want to use DiHandle you might try this with the normal
opendir(),readdir() calls.

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 25 Apr 1998 12:50:47 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: ls -R ?
Message-Id: <ltd8e5q1zs.fsf@asfast.com>

jon@blading.com writes:

> hello
> i read through the recent thread concerning ways to pring the contents of
> a dir (most settled on readdir() opendir() etc).
> is there a way to readdir() recursively?  i could find no mention in the
> online docs for readdir() and unfortunately don't have my camel book close
> at hand.
> 
> in any case, what i really want to do is to traverse a subtree
> recursively, get the name and full path of all the files there, and their
> last modified dates.

Check out the following recursive routine.  There are many possible
variations on this which would also work, and this one is not
necessarily the quickest, because the `map' and `grep' stuff could be
eliminated in favor of some manipulation within the `foreach' loop:

  sub printDirRecursively {
     my $dir = shift;
     unless (defined($dir)) {
        warn "undefined directory name";
        return (undef);
     }
     unless (opendir(DIR, $dir)) {
        warn "unable to open directory: $dir";
        return (undef);
     }
     my @itemList = sort   # ... if you want this sorted
                    map { "$dir/$_" }
                    grep { $_ !~ m/^\.\.?$/ }
                    readdir(DIR);
     closedir(DIR); # close DIR before recursing
     my $item;
     foreach $item (@itemList) {
        if (-d $item) {
           printDirRecursively($item); ### note this recursive call ###
        }
        else {
	   my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
	       $atime,$mtime,$ctime,$blksize,$blocks) = stat($item);
           if (defined($mtime)) {
              my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
	          localtime($mtime);
              printf("%04d/%02d/%02d-%02d:%02d:%02d -- %s\n",
                     $year + 1900, $mon + 1, $mday,
                     $hour, $min, $sec, $item);
           }
	   else {
              warn "unable to get modification time: $item";
           }
        }
     }
     return (undef);
  }

  printDirRecursively('.');

-- 
 Lloyd Zusman      ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Sat, 25 Apr 1998 13:34:54 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: matching man page lines
Message-Id: <35421EC2.DB9EAD29@coos.dartmouth.edu>

Ronald J Kimball wrote:
> 
> > No, not really.  What I am trying to do is match lines like:
> >
> > SYBPERL(1)                       26/Mar/98                       SYBPERL(1)
> >
> > and like:
> >
> > User Contributed Perl Documentation     User Contributed Perl Documentation
> >
> 
> How much variation is there in the strings permissible between the paired
> strings?  What is the shortest allowable length of one of the paired text strings?
> 
> /^\s+(\S.{3,})\s+\S*\s*\1\s*$/

Looks like that regexp won't work, due to lines like:

DATE(1)              User Contributed Perl Documentation              DATE(1)


However, I thought of another way to speed it up a bit.

/^\s*(\S.{2,37}\S)\s.*\1\s*$/

BTW, the initial \s+ should be \s*.  Otherwise it won't even match any of the examples.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 25 Apr 1998 12:56:31 -0400
From: "Igor I. Tovstopyat-Nelip" <itovsto@emory.edu>
Subject: newbie question
Message-Id: <Pine.GSO.3.96.980425125311.29189D-100000@larry.cc.emory.edu>

Hi everybody,

Is it possible/reasonable to learn the CGI programming and to test scripts
on a stand-alone machine (PC under the Linux OS) running an Apache server? 

Thank you for your patience.

  Igor.




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

Date: Sat, 25 Apr 1998 20:31:57 +0200
From: Daniel Stridhammar <daniel@nospamstridhammar.pp.se>
Subject: Re: newbie question
Message-Id: <35422C1D.EB820BAC@nospamstridhammar.pp.se>

Yes it will work fine when the server is configured properly with, for an
example, Perl.

Daniel



> Is it possible/reasonable to learn the CGI programming and to test scripts
> on a stand-alone machine (PC under the Linux OS) running an Apache server?





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

Date: Fri, 24 Apr 1998 22:39:46 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: PERL chmod on NT
Message-Id: <3540f7c3.71083770@news.btinternet.com>

On Fri, 24 Apr 1998 14:57:43 -0500, KenRoy Regester <kregeste@cbu.edu>
wrote:

>Does the PERL chmod function for files have the same syntax as UNIX in
>the NT version of PERL?
>

Err, yes.

But it will probably do something different.  You might want to look
at one of the Win32::* modules if you really want to change the NT
permissions.

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Sat, 25 Apr 1998 17:49:17 GMT
From: jweisgram@hotmail.com (Jim Weisgram)
Subject: Re: Perln for NT
Message-Id: <35482149.98554580@news.teleport.com>

izzy@texoma.net (Dizzy) wrote:

>Hello,
>
>	I was woundering if anyone had any basic perl info i could read up on.
>I am looking into perl but i cant seem to find any basic info besides
>bits and pieces of information.  If you dont mind please send me any
>information or web sites that might have info.  Thank You!
>
>
>Dizzy
>Dizzy
>dizzy@texoma.net

It sounds like you are not familiar with www.perl.com. If not, start there.
You'll never stop.
-- 
All opinions expressed are mine and not my employers (but they ought to be)
Jim Weisgram
Oregon Department of Transportation


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

Date: Sat, 25 Apr 1998 15:11:33 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Please stop and help.
Message-Id: <genepoolErz67A.5t3@netcom.com>

Bug (bugking@usa.net) wrote:
: you don't need to compile the perl file
: the perl is a interperter. you only need to upload it to the unix and run it

And to head off the obvious next question (how do I remove ^M from my 
scripts that I ftp from Win95 to Unix?), ftp in ascii mode.



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

Date: Sat, 25 Apr 1998 14:03:31 -0600
From: Michael Hanson <mhanson@wyoming.com>
Subject: Re: Please stop and help.
Message-Id: <35424174.364F@wyoming.com>

Jason Hall wrote:
> 
> I just had my website hosting company add a cgi-bin directory
> to my site and said it is working.  The server is unix and I am
> running win 95.  I do not have telnet access.
> 
> My question: How do I compile a perl script on my win95
> machine in order to ftp it to the unix server so it will work?
> 
> Thanks in advance!
> 
> Jason Hall
> 
> *****    Earn Free Stuff Everyday at    *****
> ****    http://www.earnfreestuff.com    *****
First of all, you should get a windows95 port of perl for your testing.
(One is available at CPAN, in ports) Then you need to write your script
with a text editor, saving your file as text, with  a .pl or .cgi
extension.
To put your file onto the server you must put it as a text (ascii)
file.  You can use wsftp or any other ftp program to do this, as well as
changing the permissions so that it is world executable.  Your ftp
program should handle that too.

Not to be picky, but perl is technically an interpreted, and not a
compiled language, although once run on the host machine, your script
will run like an executable.... but I knew what you meant anyway:)

Good luck


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

Date: 25 Apr 1998 15:36:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Problems with 'wait' under perl5.004
Message-Id: <6hsvu5$obv$1@lyra.csx.cam.ac.uk>

In article <35379340.FDD9615E@gs.com>,
Michael Francis FIR LDN  <francm@jeeves.fi.gs.com> wrote:
>I am writing a job control module in perl. This allows me to monitor the
>status of a number of processes and to check if they are running for
>more that a desired amount of time (to do this an alarm is fired about
>every 10 seconds, and the run time for the module is calculated,
>processes that are running for too long are killed and the logfiles
>emailed.)
>
>The module worked correctly under perl5.001, we have now upgraded to
>version 5.004. The symptom is that wait always returns -1 even though
>the process has spawned a number of child processes. This only occurs
>following a sigalarm . Does anybody know why this is the case? and if
>there is any way around this?

wait() returns -1 if it fails _in any way_, not just in the case
"No children".    You need to check the value of $! to find the cause
of failure.   This fact is documented in the wait(2) manpage, but
unfortunately not in  perldoc -f wait.

This script illustrates the possible cases:

$SIG{INT} = sub { print "Interrupted\n" };
$! = 13; $? = 59;
$v = wait;
print "First: $v  \$!=", 0+$!, ":$!   \$?=", $?, "\n";
my $x = $$;
if (! fork) {
sleep 1;
kill 2, $x;
exit;
};
$! = 13; $? = 59;
$v = wait;
print "Second: $v  \$!=", 0+$!, ":$!   \$?=", $?, "\n";
$! = 13; $? = 59;
$v = wait;
print "Third: $v  \$!=", 0+$!, ":$!   \$?=", $?, "\n";

The output on my platform is

First: -1  $!=10:No children   $?=-1
Interrupted
Second: -1  $!=4:Interrupted system call   $?=-1
Third: 8146  $!=13:Permission denied   $?=0

Note (a) $! is only set if wait returned -1.
     (b) $! values are platform dependent.


Mike Guy


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

Date: Sat, 25 Apr 1998 17:54:12 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: Problems with 'wait' under perl5.004
Message-Id: <slrn6k48pa.fqs.jgloudon@hyssop.bbn.com>

M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
 .
 .
>wait() returns -1 if it fails _in any way_, not just in the case
>"No children".    You need to check the value of $! to find the cause
>of failure.   This fact is documented in the wait(2) manpage, but
>unfortunately not in  perldoc -f wait.

It's worth pointing out that this is an exception to the system-calls-restart
behaviour of most functions that act as wrappers to system calls.

--
Jason Gloudon


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

Date: 25 Apr 1998 18:48:58 GMT
From: askov@rohan.sdsu.edu (David Askov)
Subject: recursive file permission changes?
Message-Id: <6htb6q$sg3$1@gondor.sdsu.edu>


This pertains to Win95 and PERL32.

To change a file's permissions such that it is no longer read-only, I just
select that file in the file manager and click on properties. From there I just
deselect read-only.

How do I do this recursively for all the files in a directory and all its
subdirectories? Is there a way to do this at the dos prompt such that I could
write a little PERL script to do it? Do PERL's file permission commands for
UNIX work in Win95 such that I could do it right from PERL?

thanks,

david


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

Date: Sat, 25 Apr 1998 19:29:48 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: recursive file permission changes?
Message-Id: <genepoolErzI5p.Jov@netcom.com>

David Askov (askov@rohan.sdsu.edu) wrote:

: How do I do this recursively for all the files in a directory and all its
: subdirectories? Is there a way to do this at the dos prompt such that I could
: write a little PERL script to do it? Do PERL's file permission commands for
: UNIX work in Win95 such that I could do it right from PERL?

>From dos prompt try either of these:

help attrib
attrib /?




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

Date: Sat, 25 Apr 1998 03:44:43 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: recursive file permission changes?
Message-Id: <35414fc9.90461859@news.btinternet.com>

On 25 Apr 1998 18:48:58 GMT, David Askov wrote :

>
>This pertains to Win95 and PERL32.
>
Eh,oh
>To change a file's permissions such that it is no longer read-only, I just
>select that file in the file manager and click on properties. From there I just
>deselect read-only.
>
>How do I do this recursively for all the files in a directory and all its
>subdirectories? Is there a way to do this at the dos prompt such that I could
>write a little PERL script to do it? Do PERL's file permission commands for
>UNIX work in Win95 such that I could do it right from PERL?
>
Any reason why you cant use  "attrib" with the /s flag ?

However as this is a Perl newsgroup a Perl solution is appropriate.  

For a look at some stuff on recursion over directories you might see
the thread with subject "ls -R"  a bit earlier.

File permissions as you probably know are altered with the function
chmod() named after its unix relative.  It retains in Win32
implementations the unix syntax however even though the underlying
concept of permissions is different.

You should examine the documentation on chmod() for more. 

You could try this:

#!/develop/bin/perl

use File::Find;

find(\&wanted,'.'); #your directory here.

sub wanted()
{
  chmod 0777,$_;
}
__END__

/J\ 
Jonathan Stowe
Some of your questions answered http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 25 Apr 1998 14:58:05 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Setting $AUTOLOAD when calling SUPER::AUTOLOAD?
Message-Id: <6hstlt$ncp$1@lyra.csx.cam.ac.uk>

In article <3540179F.678CCC24@xnet.com>, Robert Lang  <rrl@xnet.com> wrote:
>Howdy.
>
>I'm overriding the AUTOLOAD method in a subclass, poking at the
>$AUTOLOAD variable and setting an ivar depending on a test.  I'd then
>like to call SUPER::AUTOLOAD, but the $AUTOLOAD package global isn't set
>when it gets there.
>
>Essentially, I'm trying this:
>return $self->SUPER::AUTOLOAD(@_);
>
>Since that's not working, I created my own package global, then did a
>$name = $AUTOLOAD || $global_var;

Remember that the $AUTOLOAD variable is in the current package.   So
if you want to call someone else's AUTOLOAD, you must set their $AUTOLOAD.

So I'd do something like

$SuperClass::AUTOLOAD = $AUTOLOAD;
goto &SuperClass::AUTOLOAD;

Note that you have to explicitly name your superclass in the assignment.


Mike Guy


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

Date: Sat, 25 Apr 1998 18:28:04 +0200
From: Rodney Wines <Rodney.Wines@ahqps.alcatel.fr>
Subject: Strange Behavior Of "gethostbyaddr"
Message-Id: <35420F14.34349DBF@ahqps.alcatel.fr>

Can anyone tell me what (if anything) is wrong with the following?

#!/usr/local/bin/perl

use Socket;

$ip = '192.41.33.62';

($name, $aliases, $addrtype, $length, @addrs) =
	gethostbyaddr(pack('C4', split /\./, $ip), AF_INET);

$naddrs=@addrs;
print "name=$name, aliases=$aliases, type=$addrtype, length=$length,
addresses=$naddrs\n";

==============================

If I run it, with Perl 5.004_04 on Solaris 2.5.1, I get:

	name=, aliases=, type=, length=, addresses=0

An "nslookup" shows:

	Name:    worldemail.com
	Address:  192.41.33.62

If I try a different IP address, 204.146.18.33, for example, I get:

	name=www.ibm.com, aliases=, type=2, length=4, addresses=1

Can anybody tell me what's going on?

I suspect there's something screwy with the DNS for "worldmail.com", because an
nslookup of worldmail.com gives an entirely different IP address, but I don't
understand why nslookup works and gethostbyaddr doesn't.  An E-mail response
would be appreciated.

Thanks,

Rodney


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

Date: Sat, 25 Apr 1998 12:41:45 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: System call in Perl not working
Message-Id: <3542124B.491DF6E1@coos.dartmouth.edu>

Arun Gurjale wrote:
> 
> From the command line the following command works like a charm:
>         find /po/gwmail -size 0c -exec rm {} \;
                                               ^^

> The Perl script has many other things in it and we added the
> following line to the script:
>         $err_msg = system("find /po/gwmail -size 0c -exec rm {}\;");
                                                                 ^^

The \; will be changed to a simple ; by the double-quotish processing.  Try
single quotes instead.

> The script complains that the "find command is incomplete".

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 25 Apr 1998 12:43:18 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: System call in Perl not working
Message-Id: <354212A7.D5670DE6@coos.dartmouth.edu>

Tom Christiansen wrote:
> 
> In comp.lang.perl.misc,
>     "Arun Gurjale" <gurjale.arun@worldnet.att.net> writes:
> :       $err_msg = system("find /po/gwmail -size 0c -exec rm {}\;");
> 
> That's not a system call.

It is in the sense that he is making a call to the Perl function 'system'.

Perhaps 'system' call, with quotes, would be a better name for it.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 25 Apr 1998 15:11:57 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Using module outside @INC without changing @INC
Message-Id: <6hsuft$nmd$1@lyra.csx.cam.ac.uk>

Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
>I recently wanted to use a module whose path wasn't in @INC
>but without modifying @INC (because I don't want its path
>searched for later modules the caller might use - there is actually a
>good reason for this that has nothing to do with this post), and the 
>only way I could think of was:
>
>BEGIN { 
>  unshift (@INC, '/path');
>  use Foo;
>  shift @INC;
>}
>
>but I was looking for a really concise idiom since others will use
>this module and I would prefer to publish just a one-liner.

You obviously haven't tried that, as it won't work.   "use" is done
at compile time, i.e. when the BEGIN {} is compiled and before the
BEGIN {} is run.

>Of course, you can put a path in require, but then it's evaluated at 
>runtime, not compile time, and that won't do in this case.

It depends which "compile time".   A require will be obeyed when the
BEGIN {} is run, which is at compile time for the rest of the script.

So the style I'd use would be:

BEGIN {
  require "/path/Foo.pm";
  Foo->import;               # if needed
}


Mike Guy


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

Date: 25 Apr 1998 19:59:18 GMT
From: Dave Neuer <smoothie@spiritone.com>
Subject: Why doesn't this work?
Message-Id: <3541D406.78814D7C@spiritone.com>

I have written a script to extract the meta tags from several html
documents. Here's the code:

#! /usr/bin/perl

$dir = shift;

opendir (D, $dir) or die "Can't open directory: $!\n";
@files = readdir D;
closedir D;

foreach (@files){
        open (F, "<$dir/$_") or die "Can't open $_: $!\n";
        local $/ = undef;
        my $lines = <F>;
        $lines =~ s/.*(<meta\s[^>]*>).*/$1/mg;
        $file .= "$lines\n";
        close F;
}

open(F, ">metalist") or die "Can't open metalist: $!\n";
        print F $file;
close F;

This isn't working.  The script just slurps the whole html file and
prints it to the new file.  I had originally written the replacement
expression as:

$lines =~ s/.*(<meta\s.*>).*/$1/mg;

Though this didn't remove anything after the meta tag (which I realized
was because the .*> matches everything from the first attribute's first
character through the closing angle bracket of the entire HTML file),
but at least it cut out the prematch stuff.

I thought that by rewriting the expression as $lines =~
s/.*(<meta\s[^>]*>).*/$1/mg; I would be sure that only the contents of
the meta tag would match.  However the fact that the html files are
being printed to the new file intact leads me to believe that the
expression is not matching anything.  Why is this?

Thanks in advance,
Dave Neuer
 



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

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

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