[9675] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3269 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 27 19:07:15 1998

Date: Mon, 27 Jul 98 16:00:19 -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, 27 Jul 1998     Volume: 8 Number: 3269

Today's topics:
    Re: 'eval' and 'require' <mgregory@asc.sps.mot.com>
        an on-line personality test written in cgi http://www.p liamjh@my-dejanews.com
    Re: argv <jdporter@min.net>
    Re: Calling a dll from Perl <pkeefe@ix.netcom.com>
        file system operations on open files benglazer@my-dejanews.com
        Native "vmstat" in Perl ? <root@birch.netsis.com>
        Perl and NT askey@my-dejanews.com
    Re: Perl and NT (Bob Trieger)
        Perl, NT, sendmail <askeyd@seer.wustl.edu>
    Re: Perl, NT, sendmail (Bob Trieger)
        Perl5.005: any good Thread::kill workaround ideas? <hollosi@sbcm.com>
    Re: Reacting to 1 of 10 or so possible values.... Need  <jdporter@min.net>
    Re: REQ: tpj ray tracer ".map" files (I R A Aggie)
    Re: String to Ascii <stepherd@gusun.georgetown.edu>
    Re: Submit only Once <flavell@mail.cern.ch>
    Re: Submit only Once (-)
    Re: Y2K problem in PERL with localtime() (John Stanley)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 27 Jul 1998 10:35:30 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: 'eval' and 'require'
Message-Id: <r87m10m7c5.fsf@asc.sps.mot.com>


Martin Gregory <mgregory@asc.sps.mot.com> dopily continued:

> Quite a few people write things like:
> >    my $is_foo_available = eval 'require "foo"';
> 
> Many people said this.  It's a bit irritating that they didn't look and
> see that this is exactly what the script that I posted did.
> 
> It's also a bit irritating that they say that it will work when it
> blatantly does not - have you tried it with an empty foo file?

 .. now I have to appologise.  To echo another recent poster - "I'm
sorry for any one who has read this thread, will read this thread, or
is born under its shadown".  Especially I applogise for not reading
the answers properly.  Sigh.

However, I'm still a bit worried.  I know what the answer to my
question is: that

 eval 'require "foo";';
 !$@ or die;

excercises a bug in perl, so don't do it.

I also observe that 

 my $is_foo_available = eval 'require "foo"';

appears to work.

My concern is that when you do the former thing, it trashes unrelated
variables in your program.  

How do I know that the latter thing won't do this too?

Martin.


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

Date: Mon, 27 Jul 1998 21:58:49 GMT
From: liamjh@my-dejanews.com
Subject: an on-line personality test written in cgi http://www.psychometrics.co.uk
Message-Id: <6pit6p$kjn$1@nnrp1.dejanews.com>

If this is too off topic please don't flame me.

If you would like to see an example of a free and anonymous personality test
written in perl and at the same time help me with some research then visit:

http://www/psychometrics.co.uk

If you complete the questionnaire you will recieve an automatically generated
personality profile.

Thank you

Liam  Healy
Occupational Psychologist



-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Mon, 27 Jul 1998 20:59:23 GMT
From: John Porter <jdporter@min.net>
Subject: Re: argv
Message-Id: <35BCEBA1.7354@min.net>

"Learning Perl", by Randal L. Schwartz and Tom Christiansen,
O'Reilly & Associates, 1997.   1-56592-284-0.

-- 
John Porter


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

Date: Sun, 26 Jul 1998 18:54:37 -0400
From: "Pete Keefe" <pkeefe@ix.netcom.com>
Subject: Re: Calling a dll from Perl
Message-Id: <6pj0f4$6bd@dfw-ixnews9.ix.netcom.com>

I have not actually use it, but see Dada's Win32::API module at
http://194.247.167.1/DADA/PERL/

John Call wrote in message <35BC96AE.509E588D@interactive.ibm.com>...
>I am writing some code for a NT project and need to call a dll. I have
>Learnng Perl on Win32 Systems and did not see a reference to this.
>
>From what I have seen I need the Win32::API module. Is this correct. I
>looked on CPAN and could not find it and then saw a note on DejaNews
>that said that Win32::API was not on CPAN. Who knows?
>
>If anyone has done this I would like to know how you went about it.
>
>Thanks,
>
>John Call
>




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

Date: Mon, 27 Jul 1998 21:55:23 GMT
From: benglazer@my-dejanews.com
Subject: file system operations on open files
Message-Id: <6pit0b$k4p$1@nnrp1.dejanews.com>

I am writing a script to automate some user administration, and I wanted to
update a single line of my /etc/passwd file in a perl script.  Naturally, to
save my brain the pain of having to think about a solution, I stole some
sample code from a friend.  It follows:

until ( open(PASSWD, "+</etc/passwd") && flock(PASSWD, $LOCK_EX) ) {
  close(PASSWD);
  sleep 1;
}

open(NPASSWD, ">/etc/.passwd$$");

### .. do some stuff to NPASSWD and PASSWD .. ###

# Make new passwd file root read-only and
# replace old passwd file with the new one.
chmod 0644, "/etc/.passwd$$";
unlink "/etc/passwd";
link "/etc/.passwd$$", "/etc/passwd";
unlink "/etc/.passwd$$";

__END__


Unfortunately, the chmod, link, and unlinks at the end seem a little sketchy
to me, since they seem to be doing some fundamental file system stuff to
files whose handles are still open.  It would seem to be better just to close
the files and rename .passwd$$ to passwd.  However, that might defeat the
purpose of the flock(PASSWD) if the flock is lost when the file is closed
(and I suspect that this is the case -- can anyone confirm?).

In addition, it seems a bit odd that PASSWD is never unflocked.

What's going on here?  Can anyone confirm that this code is either safe or
unsafe?  Are there any suggestions for improving the code?  Should I want to
use them again later in the code, where in the code should PASSWD and NPASSWD
be closed and unflocked?


thanks,
Ben

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 27 Jul 1998 08:50:03 -0700
From: root <root@birch.netsis.com>
Subject: Native "vmstat" in Perl ?
Message-Id: <u343guok.fsf@birch.i-have-a-misconfigured-system-so-shoot-me>

I would like to construct some system monitoring tools in Perl.  The 
_eventual_ goal is to have a tool I could use to identify situations 
where some basic resource (CPU speed, available physical memory, 
etc.) is insufficient, so corrective action may be taken.  

The target OSes are Windows 95 (choke ...), Windows NT, Solaris 
2.5.1, Solaris 2.6, and Linux.  Let us _omit_ consideration of NT 
and Lose '95 for the moment ...  

The following is a "quick-and-dirty" prototype of the sort of thing 
I want to do .....  
    
    #!/usr/local/bin/perl -w
    #
    # Simple script to monitor and log CPU activity over an extended 
    # period.
    # C. Roten, 07/09/1998.
    #
    $Last=10 ;
    $Sleeptime=3 ;
    $I=1 ;
    while ( $I <= $Last ) {
        $Time=time ; 
        ($SEC,$MIN,$HOUR,$MDAY,$MON,$YEAR,$WDAY,$YDAY,$ISD) = localtime(time) ;
        $Mon = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$MON] ; 
        $Year = 1900 + $YEAR ; 
        $Time=$HOUR.":".$MIN.":".$SEC." ".$MDAY." ".$Mon." ".$Year ;
        $VMSTAT=`vmstat | tail -1 ` ;
        @CPUDATA = split " ",$VMSTAT ;
        $CPU = $CPUDATA[19] . " " . $CPUDATA[20] . " " . $CPUDATA[21] . "\n" ;
        print $Time."	".$CPU."\n" ;
        sleep $Sleeptime ;
        $I = $I + 1 ;
    }

Problem:  IMHO, the backquoted "vmstat | tail -1" on line 15.  This 
          forks not one, but two processes .. every $Sleeptime 
          seconds.  Not good.  Running this on an old SPARC 2 shows 
          96% idle .. but perfmeter sings a far different song.  
          During the 30 seconds the process runs, CPU averages about 
          20%, and peaks at 30%.  Which makes this code a 
          "Heisenberg's microscope".  

What I    Is there a Perl-native "vmstat" module that does not 
want:     require a second process to be forked ?  That might help.  



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

Date: Mon, 27 Jul 1998 21:08:06 GMT
From: askey@my-dejanews.com
Subject: Perl and NT
Message-Id: <6piq7m$gqa$1@nnrp1.dejanews.com>

Confession: I'm totally new to Perl and am not much of a programmer
(e.g.-JavaScript gives me a headache).

Problem: Running IIS 3.0 on NT 4.0. I've read dozens of posts looking for my
answer but have yet to find it. I've installed Perl successfully (from NT
Resource Kit), modified my registry to address .pl files, and created and
tested a script from a Web page. Now I've got a script I downloaded from a
web site that is a form handler designed for UNIX. I've corrected the #! line
at the beginning to tell it where Perl dwells, but I have no idea how to tell
it where to find my NT sendmail program, wSendmail. wSendmail works fine from
a command prompt and from a web page (if accessed directly in the script
directory), but I cannot call it from the original script I was tinkering
with. I've tried $DOS_path, $smtp=, and numerous other syntaxes, but the mail
will not go. Basically, I want to call wSendmail from another script on my
server. If that won't work, I'd be happy to point to our VMS mail server, if
only I knew the syntax. Is there a simple answer, besides 42, to this
rambling question?

Many thanks in advance,

Dale Askey

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Mon, 27 Jul 1998 21:37:03 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Perl and NT
Message-Id: <6pis2u$38q$1@ligarius.ultra.net>

[ posted and mailed ]

askey@my-dejanews.com wrote:
-> Confession: I'm totally new to Perl and am not much of a programmer
-> (e.g.-JavaScript gives me a headache).

Posting the same thing twice under different headings will get you nowhere 
except a bunch of killfiles.


Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


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

Date: Mon, 27 Jul 1998 16:05:51 -0500
From: Dale Askey <askeyd@seer.wustl.edu>
Subject: Perl, NT, sendmail
Message-Id: <35BCEBAF.9FA96EC1@seer.wustl.edu>

Confession: I'm totally new to Perl and am not much of a programmer
(e.g.-JavaScript gives me a headache).

Problem: Running IIS 3.0 on NT 4.0. I've read dozens of posts looking
for my answer but have yet to find it. I've installed Perl successfully
(from NT Resource Kit), modified my registry to address .pl files, and
created and tested a script from a Web page. Now I've got a script I
downloaded from a web site
that is a form handler designed for UNIX. I've corrected the #! line at
the beginning to tell it where Perl dwells, but I have no idea how to
tell it where to find my NT sendmail program, wSendmail. wSendmail works
fine from a command prompt and from a web page (if accessed directly in
the script directory), but I cannot call it from the original script I
was tinkering with. I've tried $DOS_path, $smtp=, and numerous other
syntaxes, but the mail will not go. Basically, I want to call wSendmail
from another script on my server. If that won't work, I'd be happy to
point to our VMS mail server, if only I knew the syntax. Is there a
simple answer, besides 42, to this rambling question?

Many thanks in advance,

Dale Askey

--
Pediatric Computing Facility
Washington University
St. Louis, MO
askey_d@kids.wustl.edu




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

Date: Mon, 27 Jul 1998 21:20:09 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Perl, NT, sendmail
Message-Id: <6pir38$ig8$1@ligarius.ultra.net>

[ posted and mailed ]

Dale Askey <askeyd@seer.wustl.edu> wrote:
-> Confession: I'm totally new to Perl and am not much of a programmer
-> (e.g.-JavaScript gives me a headache).

JavaScript is a headache. Pick up a book or 2 on perl and become much of a 
programmer.

-> Problem: Running IIS 3.0 on NT 4.0. I've read dozens of posts looking
-> for my answer but have yet to find it. I've installed Perl successfully
-> (from NT Resource Kit), modified my registry to address .pl files, and
-> created and tested a script from a Web page.

Great, your server and perl are working fine.

-> Now I've got a script I downloaded from a web site
-> that is a form handler designed for UNIX. I've corrected the #! line at
-> the beginning to tell it where Perl dwells, but I have no idea how to
-> tell it where to find my NT sendmail program, wSendmail. wSendmail works
-> fine from a command prompt and from a web page (if accessed directly in
-> the script directory), but I cannot call it from the original script I
-> was tinkering with. I've tried $DOS_path, $smtp=, and numerous other
-> syntaxes, but the mail will not go. Basically, I want to call wSendmail
-> from another script on my server. If that won't work, I'd be happy to
-> point to our VMS mail server, if only I knew the syntax. Is there a
-> simple answer, besides 42, to this rambling question?

You are being way too vague here and I'm not sure what you are asking.

If you are asking how to call wSendmail, that should be in the documentation 
included with the product.

If you are simply asking how to tell perl where it is located, just use the 
full pathname, e.g  'c:/wsendmail/wsendmail.exe'

If you are asking how to use wsendmail via a cgi script, you are in the wrong 
group. try:  news:comp.infosystems.www.authoring.cgi


HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


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

Date: Mon, 27 Jul 1998 22:18:31 GMT
From: Jozsef Hollosi <hollosi@sbcm.com>
Subject: Perl5.005: any good Thread::kill workaround ideas?
Message-Id: <35BCFCB6.8A4359AA@sbcm.com>

I just built the new Perl5.005 on Digital Unix and I am trying out the
cool threads.

My first test is a simple network server that starts two threads (reader
and writer) for
each accepted connection. The problem is, that when the writer decides
it is time to
finish, there is no trivial way to tell the reader to also finish,
because that is waiting
on a file descriptor (until there is some activity on that file
descriptor).

It would be nice to have something like Thread:kill, but there is none.

Any ideas?

Thanks,
Jozsef
hollosi@sbcm.com




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

Date: Mon, 27 Jul 1998 20:56:15 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Reacting to 1 of 10 or so possible values.... Need some streamlining help.
Message-Id: <35BCEAE6.1E84@min.net>

Randal Schwartz wrote:
> 
> >>>>> "John" == John Porter <jdporter@min.net> writes:
> John> for ( $reqType ) {
> John>     /^typeOne$/  and  &handle_typeOne    or
> John>     /^typeTwo$/  and  &handle_typeTwo    or
> John>                       &do_default_thing
> John> }
> 
> And broken if &handle_typeOne returns false.

Oof.  Too true.  How's this:

    for ( $reqType ) {
        s/^typeOne$/ &handle_typeOne; $& /e    or
        s/^typeTwo$/ &handle_typeTwo; $& /e    or
                     &handle_default;
    }

-- 
John Porter


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

Date: Mon, 27 Jul 1998 18:40:57 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: REQ: tpj ray tracer ".map" files
Message-Id: <fl_aggie-2707981840570001@aggie.coaps.fsu.edu>

In article <6pip7r$cut$1@goblin.uunet.ca>, smcnabb@interlog.com (Steve
McNabb) wrote:

+ can someone please email me the .map files from the current issue of the perl 
+ journal?  I'm itching to try it, but my (clueless) browser seems to
think they 
+ are image map files, and all I can get it to "save link as" is an irritating 
+ error message -- no matter how much I swear at it. :)

Try:

% lwp-rget <URL>

You *do* have lwp installed?

James


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

Date: Mon, 27 Jul 1998 17:13:00 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
To: Ken <webmaster@RemoveThisToEmail.searchpoint.com>
Subject: Re: String to Ascii
Message-Id: <35BCED5B.47FB7DE1@gusun.georgetown.edu>

Here you go:

$string = "A string to be converted into ascii";

@letters = split (//, $string);

while (@letters[$count] ne "")
{
 @ascii[$count] = ord("@letters[$count]");
 $count++;
}
$count = 0;
foreach $letter (@ascii)
{
 $count++;
 print "Letter $count = $letter\n\n";
}



Ken wrote:

> I am looking for a way to convert a string (a name) to ASCII code. The
> problem with using ord() is that it only returns the code for the first
> character. I am sure there is a way to use a loop to do this but my attempts
> have failed.
>
> I read the perl FAQ, and searched the archives.
>
> Ken
>
> ksmith@searchpoint.co m





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

Date: Tue, 28 Jul 1998 00:17:35 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Submit only Once
Message-Id: <Pine.HPP.3.95a.980728001355.16660C-100000@hpplus01.cern.ch>

On 27 Jul 1998, Jim Woodgate wrote:

> "Sam Irion" <persoft@concentric.net> writes:
> 
> > Can anyone give me any advice or direction on how to prevent the user from
> > using the browser's back button to go back to a form and repost it?
> 
> You can't stop them from going back and reposting, but just because
> it's reposted, doesn't mean you have to accept it... :)

Right, but this is not a perl language issue.  f'ups set.

> You could generate a random number, store it in a hidden field

Yes...

> (which
> would need to be recalculated on a form reset),

Form reset is a purely local browser function.  There is no way you can
persuade a browser to reliably calculate anything, and, as the server is
not informed, there's not a damned thing you can do about it.

Maybe you meant to say "reload"?

[I agreed with the rest of what you said, b.t.w]




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

Date: Mon, 27 Jul 1998 22:42:37 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Submit only Once
Message-Id: <35bd021f.144248121@news2.cais.com>

malch@malch.com (Malcolm Hoar) Said this:

>In article <35bca561.120600557@news2.cais.com>, root.noharvest.\@not_even\here.com wrote:
>>>For example, have the form processing script prevent more
>>>than "x" submissions from the same IP address in "y" seconds.
>>
>>Or perhaps....  have the form created by another script that generates
>>a unique ID, and then in the recieving script, if you encounter a
>>"used" ID, don't allow the process to continue.  If the ID has not
>>been seen before, good - send the message.
>
>Checking the IP is probably more effective against 'bots' which,
>in my experience, cause many more multiple-submissions than
>humans. May not work with round-robin proxies but we're getting
>further and further off-topic for c.l.p.m ....
>

But bots don't tend to repost a form... I think if I understood the
original purpose of this thread, bots *shouldn't* be a problem.  Of
course, as soon as you say that, someone invents a bot that will
become a problem.




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

Date: 27 Jul 1998 21:17:28 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6piqp8$9kr$1@news.NERO.NET>

In article <DH4v1.7$NJ5.182329@news2.voicenet.com>,
Matt Knecht <hex@voicenet.com> wrote:
>John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>>I fail to see how using a function that fails on a format overflow (that
>>does not yet exist) could kill existing code.
>
>I'll give you an example that I depend on in *many* of my own programs.

An example of using a function that does not yet exist?

>I think you're missing the point.  %2d is not asking for two digits, nor

I think you're missing the point. That is exactly what it looks like.
That is exactly what happens, in most cases. 

>>I would think a module to either replace the core of printf or create a
>>error-handling printf under a new name would be better.
>
>printf is reasonably complex already, and you want to add a new level of
>complexity with what you're asking.

Yes. So? If you don't want it, don't use the module. 

># What happens if we want arbitrary trimming?

I don't know. I don't think anyone has talked about "arbitrary"
trimming. All I've mentioned is returning the number of characters in
the format or making it obvious that it can't be done.

>Better to use
>substr and tell it exactly what to print out (And, at that point, I
>could use print.).

And write lots of the same code over and over again. Why do you object
to a module that provides this funtion? Do you object to every module
that you don't intend on using?



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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