[7873] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1498 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 18 11:17:28 1997

Date: Thu, 18 Dec 97 08:00:26 -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           Thu, 18 Dec 1997     Volume: 8 Number: 1498

Today's topics:
     Re: <SELECT MULTIPLE >  Script only gives one value. Ca (Neil Burnett)
     Adding user to NT domain <guido@sportnet.nl>
     Re: Changing passwd <adavid@netinfo.com.au>
     Re: Changing passwd <webmaster@fccj.cc.fl.us>
     Re: Cmd-Line perl via rsh <adavid@netinfo.com.au>
     Re: flow control <prl2@lehigh.edu>
     Re: getting list of directories, returned as an array <merlyn@stonehenge.com>
     Re: Help Needed modifying a text file using perl (Tad McClellan)
     How to Monitor System Resources used by CGI? daveydoo@sprynet.com
     Re: Iteration within a foreach loop <barnett@houston.Geco-Prakla.slb.com>
     Re: Iteration within a foreach loop (Paul)
     Re: Iteration within a foreach loop (Paul)
     Re: Iteration within a foreach loop (Paul)
     Re: NEED:  Fast, Fast string trim() (Tony Bowden)
     Newbie can't add the -w flag to perl to get useful warn (Dave Reed)
     Re: No Flock! -- Now What? <tchrist@mox.perl.com>
     Re: Perl editor needed (Jeroen Kustermans)
     Re: Q: sorting hash by category (Andrew M. Langmead)
     Re: Q: sorting hash by category (Tad McClellan)
     Re: running perl with cgi on a NT? <webmaster@fccj.cc.fl.us>
     Re: searchable archive (Tad McClellan)
     Re: Sockets/HTTP Problem -- Anyone? <merlyn@stonehenge.com>
     Source to count downloads on a file... help please <ralphk@netpro.com>
     what is the equivalent of fflush in perl <turk2@frontiernet.net>
     Re: what is the equivalent of fflush in perl (Mike Stok)
     Re: What kind of machine wouldn't support FLOCK? (Jeffrey R. Drumm)
     Re: What kind of machine wouldn't support FLOCK? <tchrist@mox.perl.com>
     Why can't I open with Perl5 dbm's created in Perl4? <bruno@prior.ftech.co.uk>
     Re: Win32 Perl with MS Access <lxliu@lucent.com>
     xbase Problems (Patrick Gundlach)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Dec 1997 12:06:48 GMT
From: spectd@horus.sara.nl (Neil Burnett)
Subject: Re: <SELECT MULTIPLE >  Script only gives one value. Can you help?
Message-Id: <349911b3.180805@news.eunet.be>

On Thu, 18 Dec 1997 01:42:24 -0800, Craig <rcd@kiwi.net> wrotz:

>Example:
><SELECT MULTIPLE SIZE=2 NAME="name">
><OPTION>something
><OPTION>somethingelse
></SELECT>
>
>If you have multiple values of a the SELECT tag in a form, the contents
>get sent to the Perl script like this:
>
>&name=something&name=somethingelse
>
>In which case the first "name" gets over written and the final value of
>"name" is "somethingelse".
>
>The code I use is like this:
>$name = $in->param('name');
>
>How can I capture all values of "name"?? I would appreciate it if you
>could help.
>
Just use:
@name = $in->param('name');
instead. - Neil


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

Date: Thu, 18 Dec 1997 16:08:43 +0100
From: "Guido Smit" <guido@sportnet.nl>
Subject: Adding user to NT domain
Message-Id: <67beed$4od$1@news2.xs4all.nl>

Hi there,
I've made a perl script to add users to a NT domain. This work pretty good
with the utils from the resource kit (addusers and usrtogrp). But I want to
user the win32 extensions from the perl module win32. UserCreate does not
create a user and I cannot find any documentation on this.
Does anyone know how to do this and my next question, how can I define flags
with this command.

The next problem is probably a NT problem, not a perl problem, but perhaps
anyone can tell me how I can resolve this in perl. When I create a user
using the perl script, the user has to change his password at the next
logon. I don't want this. I can't find any command for this.

guido@sportnet.nl




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

Date: Thu, 18 Dec 1997 21:42:49 +1100
From: Anthony David <adavid@netinfo.com.au>
Subject: Re: Changing passwd
Message-Id: <3498FE29.ED81705F@netinfo.com.au>



Philip Ling wrote:

> Hi,
>
> Is there a way for a non-root user to change other users' password ?

This is a security question, not a Perl question. You need to have a
setuid program
(yes this can be Perl or C or Fortran or ...) and you need to have the
appropriate
authority granted to you to run the program. This sort of thing could be
used by
adminstrators who are only given restricted priveliges. There are other
methods
available that you can also research but they all require the granting
of privelige.

>  If other users can pass the uid and existing password as parameters.
> Of course, the script is in perl.
>

Well, there should be only ONE person who knows the user's password, and
that
is the user himself. If you DO know the password they either gave it to
you
or you "stole" it. In the first case,  the setuid program  'passwd' will
suffice.
In the second case, describe carefully to you System Administrator what
happened.
On second thoughts, do that for the first case too.

--
Anthony David  |     Opinions expressed ARE
Anthony David & Associates |     those of my employer




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

Date: Thu, 18 Dec 1997 07:16:49 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Re: Changing passwd
Message-Id: <349914d6.0@usenet.fccj.cc.fl.us>

Well, if this is UNIX, and you are willing to install 'expect' (which would
be required to get around a /dev/tty or /dev/pty issues - Ref: Larry Wall.)

I have a cgi with Web-interface which will aloow THE USER to change their
own passwd (if they don't know it, or if it has expired, etc. the
SysAdmin/ROOT will have to do it for them.  You know security reasons :-)

Anyways, if you are inetrested, pls drop me an e-mail and I will send it
out; one caveat, however, I cannot offer any support, per se, as I am just
learning Perl as well :-)

HTH,
Bill

PS - This program was the second Perl/Expect project I worked on, so it is
pretty raw, clean, but raw none the less.  Just thought I would warn you...

Anthony David wrote in message <3498FE29.ED81705F@netinfo.com.au>...
>
>
>Philip Ling wrote:
>
>> Hi,
>>
>> Is there a way for a non-root user to change other users' password ?
>
>This is a security question, not a Perl question. You need to have a
>setuid program
>(yes this can be Perl or C or Fortran or ...) and you need to have the
>appropriate
>authority granted to you to run the program. This sort of thing could be
>used by
>adminstrators who are only given restricted priveliges. There are other
>methods
>available that you can also research but they all require the granting
>of privelige.
>
>>  If other users can pass the uid and existing password as parameters.
>> Of course, the script is in perl.
>>
>
>Well, there should be only ONE person who knows the user's password, and
>that
>is the user himself. If you DO know the password they either gave it to
>you
>or you "stole" it. In the first case,  the setuid program  'passwd' will
>suffice.
>In the second case, describe carefully to you System Administrator what
>happened.
>On second thoughts, do that for the first case too.
>
>--
>Anthony David  |     Opinions expressed ARE
>Anthony David & Associates |     those of my employer
>
>




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

Date: Thu, 18 Dec 1997 21:50:25 +1100
From: Anthony David <adavid@netinfo.com.au>
Subject: Re: Cmd-Line perl via rsh
Message-Id: <3498FFF1.9902F16C@netinfo.com.au>



Matthew Forder wrote:

> OK. I'm trying to execute the following command-line perl script via the
> rsh command, with no success:
>
> rsh hostname /usr/local/bin/perl -p -i.old -e '$_ !~
> /^[^:]+:(\*{2,})\D+\1:/ && $_ =~
> s/^username:[^:]+:/username:cryptedpasswd:/ /testdir/shadow
>
> If executed as above, the error is returned:
> ksh: syntax error at line 1 : `(' unexpected
>
> If I execute this cmd-line..: rsh hostname "/usr/local/bin/perl -p -i.old
> -e '$_ !~ /^[^:]+:(\*{2,})\D+\1:/ && $_ =~
> s/^username:[^:]+:/username:cryptedpasswd:/ /testdir/shadow"

In both cases there seems to be a missing ' in there.As a general rule, I
quote my rsh and su -c commands in ' not " as you are never
quite sure when you local shell will do substitutions for you.

eg rsh hostname "ls -l $HOME/*.pl"

--
Anthony David     |     Opinions expressed ARE
Anthony David & Associates |     those of my employer




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

Date: 18 Dec 1997 13:40:23 GMT
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: Re: flow control
Message-Id: <01bd0bba$7f2e3840$3e03b480@mm>

Thanks for the lead.  I had ended up with:

	my $dbh;
	until (defined $dbh) {
		$dbh = DBI->connect($datasource, $user, $pass)
			or eval { ... }

What differences between 'do' and 'eval' might I be concerned with?


Charles DeRykus <ced@bcstec.ca.boeing.com> wrote in article
<ELCo3I.FuF@bcstec.ca.boeing.com>...
> This's kinda ugly too but try: 
> 
>   until (defined (my $dbh)) {
>   	$dbh = DBI->connect("dbi:Oracle:sa71", $uname, $upass)  
>           or do { ... };
> 
> 
> HTH,
> --
> Charles DeRykus
> 

-- 
Phil R Lawrence
Systems and Networking Development Services
Programmer/Analyst
prl2@lehigh.edu


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

Date: 18 Dec 1997 06:04:48 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: getting list of directories, returned as an array
Message-Id: <8cpvmuu7in.fsf@gadget.cscaper.com>

>>>>> "Chip" == Chip Salzenberg <chip@mail.atlantic.net> writes:

Chip> According to rjk@coos.dartmouth.edu:
>> Joshua J. Kugler wrote:
>>> This doesn't work:
>>> find({push(@dirlist, $File::Find::name) if -d;}, '.');
>> 
>> In this one, you're executing a block of code and passing the result
>> to find.

Chip> Well, he's _trying_ to.  He's getting a syntax error because Perl thinks
Chip> it's a badly typed anonymous hash.  A leading "do" on the block would be
Chip> correct syntax for that buggy approach.  :-)

Or perhaps what I had really meant to type was sub {...} but
left out the "sub" part.

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

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


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

Date: Wed, 17 Dec 1997 22:08:09 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help Needed modifying a text file using perl
Message-Id: <9j7a76.k15.ln@localhost>

Dan Roberts (roberts_d@bms.nospam.com) wrote:

: I am stuck in being able to modify an existing text file using perl.
: What I have is a directory of files of the form auto.txt
: and the contents of the file look like
: <wagon
: 12948234724232
: 2121212121298128182182810


: what I need to do is change only the very first line of the file from 
: <wagon to something that would match the existing file name
: so for instance
: if the test file is currently called
: car1245.txt
: I would like to have the first line of the car1245.txt file read
: <car1245-wagon 
: instead of it reading
: <wagon 
: as it now does.

: these changes would occur for all such named files within the same
                                ^^^^^^^^^^^^^^^^^^^^
: directory.


(mine doesn't do that part)


: I just can't figure out who to have perl swap out the old line and write
: in a new one for me.

: Could someone please help me out??.>thanks!!.>Dan


   perl -p -i -e 's/^<(\w+)/<$ARGV-$1/ if $. == 1' car1245.txt


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 18 Dec 1997 08:51:09 -0600
From: daveydoo@sprynet.com
To: daveydoo@sprynet.com
Subject: How to Monitor System Resources used by CGI?
Message-Id: <882456151.1069547521@dejanews.com>

I am testing a Perl CGI script and I fear that it uses a great deal of
the server's resources when running.  The client's server runs
UNIX/Apache.

Is there any way that, as a remote user, I can monitor the system
resources my script uses?  I am not able to telnet to the site to run a
UNIX command line session, but, of course, I have access to UNIX commands
via the CGI's.

I suspect the answer begins with "Go back and learn UNIX, then..." but
any help is appreciated.

Dave
www.davesweb.com

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


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

Date: Thu, 18 Dec 1997 08:21:03 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Iteration within a foreach loop
Message-Id: <3499314F.595103AC@houston.Geco-Prakla.slb.com>

Paul wrote:
> 
>         Here's the snippet (we will be checking our named.boot files):
> 
>         foreach $domname (sort keys %prifor) {
>                 @buf = split /\n/, `whois $domname`;

This line jumped out at me, but until I toyed with it for a while, I
couldn't fathom why.

You are telling the interpreter to do a whois on the key to your hash,
not the value.  If %prifor has one, two, and three as the 'key' to your
hash, your script is trying to do a whois one, whois two, and whois
three to look them up.

Change this to `whois $prifor{$domname}`

That should work much better.  Well....it will at least get you some
information.  After that, you're on your own, again.  ;-)

HTH.

Dave

> 
>                 foreach ( @buf ) {
>                         if ( /$match_this_puppy/ ) {
>                                 <ITERATE TWO MORE LINES HERE>;
>                                 ...do somethig way cool here;
>                         }
>                 }
>         }
> 
>         Any clues for the clueless?
> 
> Thanks,
> Paul

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: 18 Dec 1997 15:20:07 GMT
From: paul@pmcg.com (Paul)
Subject: Re: Iteration within a foreach loop
Message-Id: <67bev7$epk$1@la-mail4.digilink.net>

In article <3498D6A7.F1292E9E@sirius.com>
Jim Bowlin <bowlin@sirius.com> wrote:

> I'm clueless here Paul.  What is the question?

	Sorry. I did not explain very well...

> Paul wrote:
>> 
>>         Here's the snippet (we will be checking our named.boot files):
>> 
>>         foreach $domname (sort keys %prifor) {
>>                 @buf = split /\n/, `whois $domname`;
>> 
>>                 foreach ( @buf ) {
>>                         if ( /$match_this_puppy/ ) {
>>                                 <ITERATE TWO MORE LINES HERE>;

	I'm looking for the correct way to iterate through
two more lines at this point in the loop. I am matching the

	Domain name servers:

line in the whois record and I want to count through the blank
line in the record to the nameserver lines in the record. I've tried
'next' and a gazillion other things. There is no hint in the Camel
or Llama books, I can't find anything in the man pages or faqs.
I'm stumped. I have a graceless and ugly workaround, but I
was hoping to find a 'perlish' way to get the job done.

>>                                 ...do somethig way cool here;
>>                         }
>>                 }
>>         }
>> 
>>         Any clues for the clueless?





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

Date: 18 Dec 1997 15:24:23 GMT
From: paul@pmcg.com (Paul)
Subject: Re: Iteration within a foreach loop
Message-Id: <67bf77$f1j$1@la-mail4.digilink.net>

In article <3499314F.595103AC@houston.Geco-Prakla.slb.com>
Dave Barnett <barnett@houston.Geco-Prakla.slb.com> wrote:

> Paul wrote:
>> 
>>         Here's the snippet (we will be checking our named.boot files):
>> 
>>         foreach $domname (sort keys %prifor) {
>>                 @buf = split /\n/, `whois $domname`;
> 
> You are telling the interpreter to do a whois on the key to your hash,
> not the value.  If %prifor has one, two, and three as the 'key' to your
> hash, your script is trying to do a whois one, whois two, and whois
> three to look them up.
> 
> Change this to `whois $prifor{$domname}`

	When I read the named.boot file I create the hash with
$hashname{$domain_name} = $primary_nameserver_ip_number.
Feeding the key to whois works just fine.

Thanks anyway, though,
Paul



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

Date: 18 Dec 1997 15:44:57 GMT
From: paul@pmcg.com (Paul)
Subject: Re: Iteration within a foreach loop
Message-Id: <67bgdp$g0f$1@la-mail4.digilink.net>

In article <67bf77$f1j$1@la-mail4.digilink.net>
paul@pmcg.com (Paul) wrote:

> In article <3499314F.595103AC@houston.Geco-Prakla.slb.com>
> Dave Barnett <barnett@houston.Geco-Prakla.slb.com> wrote:
> 
>> Paul wrote:
>>> 
>>>         Here's the snippet (we will be checking our named.boot files):
>>> 
>>>         foreach $domname (sort keys %prifor) {
>>>                 @buf = split /\n/, `whois $domname`;
>
>> Change this to `whois $prifor{$domname}`
> 
> 	When I read the named.boot file I create the hash with
> $hashname{$domain_name} = $primary_nameserver_ip_number.

Sorry, it's
	 $hashname{$domain_name} = $zone_file_name

Paul




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

Date: 18 Dec 1997 15:45:08 GMT
From: tony@crux.blackstar.co.uk (Tony Bowden)
Subject: Re: NEED:  Fast, Fast string trim()
Message-Id: <882459947.266886@sparc.tibus.net>

Matz Kindahl (matkin@Owein.DoCS.UU.SE) wrote:
: > Any advance?
 
: I tried the following version; seems to be ~25% faster than my
: previous version.
: 5) $_ = " $_ "; tr/ \n\r\t/ /s; $_ = substr($_,1,-1)

On short strings:
  Benchmark: timing 50000 iterations of Exp1, Exp2...
      Exp1:  2 secs ( 1.69 usr  0.00 sys =  1.69 cpu)
      Exp2:  1 secs ( 1.21 usr  0.00 sys =  1.21 cpu)

On long strings:
  Benchmark: timing 50000 iterations of Exp1, Exp2...
      Exp1: 10 secs ( 9.44 usr  0.00 sys =  9.44 cpu)
      Exp2: 10 secs ( 9.25 usr  0.00 sys =  9.25 cpu)

A nice advance, but unfortunately not that noticable on long strings.

Still the best to date though ;)

Thanks

Tony
-- 
-----------------------------------------------------------------------------
 Tony Bowden |  tony@tmtm.com / NooNoo@teletubbies.org / http://www.tmtm.com/
 Belfast, NI |         no-one can convince me we aren't gluttons for our doom
-----------------------------------------------------------------------------


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

Date: Thu, 18 Dec 1997 10:48:26 -0500
From: daveSTOP*SPAMreed@webshowplace.com (Dave Reed)
Subject: Newbie can't add the -w flag to perl to get useful warnings
Message-Id: <daveSTOP*SPAMreed-1812971048260001@d200.b70.cmb.ma.ultra.net>

I've been told to "add the -w flag to perl to get useful warnings."

Not having the slightest idea how to do that, I turned to LEARNING PERL by
Schwartz & Christiansen, only to be told to "turn on the -w option from
the command line, which you should always do for safety's sake."

How?  Type "perl -w" before the filename, like when using "perl -c"?

Everyone seems to assume that Perl newbies are already programmers.

Is there a useful place to start for those of us who never used Telnet before?

(I've been using a Mac almost daily since 1984 and doing HTML for years,
but when it comes to Perl it seems like all the books on "How to Learn
Greek" are written in Greek.)

Help?

- Dave Reed


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

Date: 18 Dec 1997 15:13:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: No Flock! -- Now What?
Message-Id: <67bejl$b4s$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, syarbrou@ais.net (Steve) writes:
:Only Linux with perl 5.004_04 seems to support in on the UNIX end.

Please stop saying that, or file a specific bug report. 
What you are saying here is catastrophic in the extreme,
if it is true, which I am prepared to doubt.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


Fine, let them give me the endless crap.   --Andrew Hume


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

Date: Thu, 18 Dec 1997 14:37:59 GMT
From: NightLightWEGSPAM@webcity.nl (Jeroen Kustermans)
Subject: Re: Perl editor needed
Message-Id: <349d2a2f.8087868@news.xs4all.nl>

On Tue, 16 Dec 1997 11:40:58 -0700, "J. Masterson"
<webmaster@everyweek.com> wrote:

>Kent Scheidegger wrote:
>> 
>> Bill Guindon <billg@networkapparel.com> wrote:
>> 
>> : Larry Hanlon wrote:
>> : >
>> : > Hello, just found first lesson in PERL. I need to find a editor
>> that doesn't
>> : > add a CR to the end of each line. What I am doing is the
>> programming in a
>> : > WIN95/DOS environment and when the scripts are run on a UNIX
>> platform the
>> : > CR's create errors. Please reply to e-mail as the news server is
>> sometimes
>> : > buggy.
>
>I use WS_FTP to upload my scripts-- setting it to 'ascii' works great,
>no further manipulations needed, aside from a chmod to make it
>executable.

I made a script for this, just put it in your (UNIX-)path and run it
in the dir where you want to chmod your scripts. It uses the command
to_dos and to_unix, which converts your files. On some systems, these
commands are also available with the name dos2ux and ux2dos.

Best wishes,
Jeroen

#!/usr/sbin/perl

###############################################
# ux2dos.pl							#
# Include in package: -						#
#								#
# Perl Routines to convert all the ascii-
#
# files in the in the directory from UNIX
#
# to MSDOS-format						#
#								#
# Author: J.Kustermans						#
# nightlight@webcity.nl						#
#								#
# Copyright 1997 Jeroen Kustermans				#
# Rooseveltlaan 146-4						#
# 1078 NS Amsterdam						#
# The Netherlands						#
#								#
###############################################

# put the dir into a file in the temp-directory put that hold into the
# array "dirlist" and remove the temperory file

system("ls -a ./* > /tmp/dirlist.tmp");
open(TMP,"/tmp/dirlist.tmp");
@dirlist = <TMP>;
close TMP;
chop(@dirlist);
unlink("/tmp/dirlist.tmp");

$index = 0;
while($dirlist[$index] ne "")
{
   system("to_dos $dirlist[$index] ./tmp.pl");
   system("mv ./tmp.pl $dirlist[$index]");
   $index++;
}

unlink("./tmp.pl");
system("chmod 755 ./*");

#END




And back:

#!/usr/sbin/perl

###############################################
# ux2dos.pl							#
# Include in package: -			    			#
#					    			#
# Perl Routines to convert all the ascii-
#
# files in the in the directory from MSDOS  			#
# to UNIX-format			    			#
#					    			#
# Author: J.Kustermans 			    			#
# nightlight@webcity.nl
#
#					    			#
# Copyright 1997 Jeroen Kustermans	    			#
# Rooseveltlaan 146-4			    			#
# 1078 NS Amsterdam			    			#
# The Netherlands			    			#
#					    			#
###############################################

# put the dir into a file in the temp-directory put that hold into the
# array "dirlist" and remove the temperory file

system("ls -a ./* > /tmp/dirlist.tmp");
open(TMP,"/tmp/dirlist.tmp");
@dirlist = <TMP>;
close TMP;
chop(@dirlist);
unlink("/tmp/dirlist.tmp");

$index = 0;
while($dirlist[$index] ne "")
{
   system("to_unix $dirlist[$index] ./tmp.pl");
   system("mv ./tmp.pl $dirlist[$index]");
   $index++;
}

unlink("./tmp.pl");
system("chmod 755 ./*");

#END

P.S.: for email-reply, remove "WEGSPAM" from the email-address.
So mail to: NightLight@webcity.nl and you will get a reply back asap.


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

Date: Thu, 18 Dec 1997 14:46:30 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q: sorting hash by category
Message-Id: <ELE3pI.Bn8@world.std.com>

"Xah" <xah@best.com> writes:

>What's a *GOOD* way to do it? A guide will do me good. Thanks. 

The way shown in the FAQ question "how do I sort a hash (optionally by
value).

<URL:http://www.perl.com/CPAN/doc/manual/html/pod/perlfaq4/
How_do_I_sort_a_hash_optionaly.html>
-- 
Andrew Langmead


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

Date: Thu, 18 Dec 1997 08:10:00 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Q: sorting hash by category
Message-Id: <orab76.tu.ln@localhost>

Xah (xah@best.com) wrote:
: Suppose I have a hash like this

[ snip data, see below ]

: I want to sort files into categories by extensions then sort them by count
: value. The result should print like this

: 75	mandellaIcon.gif
: 7	cardioidParallelTangents.gif
: 6	pedalCosQuetzal.gif
: 6	parabolaReflector.gif
: 6	nebula_HeartIcon.gif
: 6	invParallel4.gif
: 4	LimaconGG2_2.gif
: 1	wallpaperSmall15.gif
: 1	involuteCircleRainbow.gif

: 1	astroidTrammel.fig
: 1	nephroidByEnvOfCircleProof.fig

[ snip rest of desired output ]

: What's a *GOOD* way to do it? A guide will do me good. Thanks. 


Your specification leaves out describing a couple of things that
it should probably describe.

Since you left them unspoken, the developer (me) is free to
choose ANY interpretation. He (me again), being Lazy and Impatient,
will likely choose whichever is easier to code.

This may or may not produce the results that you really want.


1) What order should the _groups_ be sorted in?

   a) alphabetically by the filename extension (I choose this)

   b) numerically by whichever group has the highest "count"


2) What order within a group when the "count" is equal?

   a) it doesn't matter (I choose this)

   b) "stable" sort (ie. in the same order as stored in the hash
                    (which does not appear ordered to people))

   c) alphabetically by filename

--------------------------------
#!/usr/bin/perl -w

# about 1000 pairs.
#       ^^^^^^^^^^
# That's good, because I would do more that one part of the below
# differently if the hash was anywhere approaching "large"
#
%hh = (
'wallpaperSmall15.gif' => 1,
'mandellaIcon.gif' => 75,
'astroidTrammel.fig' => 1,
'parabolaReflector.gif' => 6,
'nephroidByEnvOfCircleProof.fig' => 1,
'mathGraphicsGallery.html' => 17,
'invParallel4.gif' => 6,
'cardioidParallelTangents.gif' => 7,
'pedalCosQuetzal.gif' => 6,
'nebula_HeartIcon.gif' => 6,
'LimaconGG2_2.gif' => 4,
'involuteCircleRainbow.gif' => 1,
'deltoidTangent1.gsp' => 2,
'newtstalks1.html' => 1,
'ellipseGenPointwise.mov' => 1
);


# get a unique list of filename extensions as keys of %extensions
foreach (keys %hh) {
   $extensions{$1} = 1 if /.*\.(.*)/g;
}


# for each type of filename extension
foreach $ext (sort keys %extensions) {

   # get the keys that match this extension
   @fnames = grep /\.$ext$/, keys %hh;

   # sort (some elements from) hash by value, just like the Perl FAQ describes
   foreach $fname (sort {$hh{$b} <=> $hh{$a}} @fnames) {
      printf "%-7d %s\n", $hh{$fname}, $fname;
   }
   print "\n";

}
--------------------------------


'7' in the printf, rather than '-7' makes better looking output IMO
(but '-7' matches your example output)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 18 Dec 1997 07:05:32 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Re: running perl with cgi on a NT?
Message-Id: <34991223.0@usenet.fccj.cc.fl.us>

Hi, I use IIS 4.0 Beta 3 with no problems under NT 4.0 Wrkstation.
The Activeware (now Activestate at http://www.activestate.com/) Perl
implementation is just fine.  IE 4.0 has a minor bug about stripping
comments incorrectly, but that's about it.

Other than clearly documented differences, I have had no trouble running the
same code I use on my SunOS 5.5.x Ultra1 (Solaris) without change on my NTWS
4.0 box at home :-)

I use Build 313 at home (but I hear Santa Claus is bringing Build 314 to
those of you who are naughty OR nice...)

HTH,
Bill

Stephan Mankopf wrote in message <3498F65F.73CA@rokd.de>...
>Calle ]sman wrote:
>>
>> I wonder if someone want to share experience with running
>> some cgi-scripts on a NT-webserver.
>>
>> What differs from running it on a unix?
>> what do one has to think about regarding security?
>>
>> is there some neat webserver one can download that I can run on W95/NT so
I
>> can try out the stuff at home? (the computer
>> shall not be connected to the net, I just want to see that the
cgi-scripts
>> works as supposed to)
>>
>> what things exist on NT instead of sendmail?
>>
>> /Calle
>>
>>
**************************************************************************
>> *         *         My homepage about the author Tom Holt:
*
>> *        /_\        http://www.mdstud.chalmers.se/~md4calle/holt/
*
>> *     { ~._.~ }
*
>> *      (  Y  )      other things like OnLine Guitar Archive linkpage
*
>> *     ( )~*~( )     and heaps of musiclinks can be found at
*
>> *     (__)-(__)     http://www.mdstud.chalmers.se/~md4calle/
*
>>
**************************************************************************
>We use Microsoft Internet Information Server 2.0 or 3.0 with
>Perl5 for Win32 (FAQ at
>http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html)
>in our Intranet (IIS not in the WEB!). You could download Perl5
>for Win32 from ftp://gate.rokd.de/pub/swhup/ [pw32i306.exe].
>As an SMTP-Gateway you could use "blat1.5" Part of NT4.0
>Resource-Kit (http://gepasi.dbs.aber.ac.uk/softw/Blat.html)
>Greetings stev
>--
>Stephan Mankopf
>Phone     ++49 (521) 1457-308 (business)
>FAX       ++49 (521) 1457-180 (business)
>e-Mail    stephan.mankopf@rokd.de
>Internet: http://www.rokd.de/soha/




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

Date: Wed, 17 Dec 1997 21:59:18 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: searchable archive
Message-Id: <m27a76.gu4.ln@localhost>

Stephan Vladimir Bugaj (bugaj@bell-labs.com) wrote:
: Is there a (searchable) archive of comp.lang.perl.misc, preferably
: with a web interface?  


   http://www.dejanews.com

archives most newsgroups, including c.l.p.m


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 18 Dec 1997 06:03:30 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Craig Pearlman <craig@xu1.medscape.com>
Subject: Re: Sockets/HTTP Problem -- Anyone?
Message-Id: <8cu3c6u7kt.fsf@gadget.cscaper.com>

>>>>> "Craig" == Craig Pearlman <craig@xu1.medscape.com> writes:

Craig> What I've been trying to do is write a script that will function
Craig> (somewhat) as a proxy server for HTTP requests.  The idea is to be able
Craig> to log to a file the headers both to and from the browser and Web server
Craig> to try to track down a rather annoying problem we've been having.

My Anonymizing Proxy Server that I wrote for WebTechniques is a
full-function HTTP/Gopher/FTP proxy in about 90 lines of Perl.  It'd
be trivial to add a few lines of code to it to write down all the
transactions that pass through it.  (In fact, I think you'd just need
to uncomment some of the debug stuff that's commented out. :-)

See it at

		http://www.stonehenge.com/merlyn/WebTechniques/

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

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


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

Date: 18 Dec 1997 08:11:00 -0700
From: "Ralph Krausse" <ralphk@netpro.com>
Subject: Source to count downloads on a file... help please
Message-Id: <01bd0bc7$39c1c6c0$2a5108d0@ralphk>

Hello,

	I am looking for some perl source that will allow
me to count the number of downloads from my site.

Thank you,
Ralph Krausse

ralphk@primenet.com


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

Date: 18 Dec 1997 13:11:27 GMT
From: Vijay Veeranna <turk2@frontiernet.net>
Subject: what is the equivalent of fflush in perl
Message-Id: <34994957.61BC@frontiernet.net>

Hi,

I have a perl script which runs as a deamon and logs continuously
to a log file. The problem I am facing is the log file is  
 updated after almost 4-5 hours because of the buffering. Is there
any way of doing an fflush to my log file descriptor similar to
what we do in C language?

Any suggestions are welcome.
P.S. Please respond with a copy to vijay.veeranna@cbis.com

Thanks
Vijay Veeranna
Analsyt
Cincinnati Bell Information Systems


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

Date: 18 Dec 1997 08:33:12 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: what is the equivalent of fflush in perl
Message-Id: <67b8mo$pm$1@stok.co.uk>

In article <34994957.61BC@frontiernet.net>,
Vijay Veeranna  <turk2@frontiernet.net> wrote:

>I have a perl script which runs as a deamon and logs continuously
>to a log file. The problem I am facing is the log file is  
> updated after almost 4-5 hours because of the buffering. Is there
>any way of doing an fflush to my log file descriptor similar to
>what we do in C language?

You can set a filehandle to autoflush after each print, the FileHandle
module lets you say

  use FileHandle;

  ...

  autoflush LOGFH 1;

  ...

(assuming LOGFH is the opened file handle to the log file)  See the
FileHandle man page for more details (and possibly other modules to use.)

If you're using an old perl you can use $| to set autoflushing on the
currently selected filehandle, code something like this can be used
(untested typed in code alert...)

  $oldFh = select (LOGFH);
  $| = 1;
  select )$oldFh);

or if you need it in one line

  select ((select (LOGFH), $| = 1)[$[]);

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Thu, 18 Dec 1997 13:13:26 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: What kind of machine wouldn't support FLOCK?
Message-Id: <34992010.495545466@news.mmc.org>

On Thu, 18 Dec 1997 03:42:11 GMT, syarbrou@ais.net (Steve) wrote:

>I have done extensive testing of flock on unix systems anyways and
>several systems have it, but only Linux truely seems to support it.
>All the other flavors of UNIX accept the command but do not work.
>
>Steve

Hmm. Must be pretty obscure versions of Unix, or your understanding of flock's
operation is incomplete. Works fine here . . . and I don't use Linux. Perhaps
you're confusing advisory vs. kernel-enforced locking? Seems I remember reading
somewhere that Linux supports the latter.

-- 
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
420 Cumberland Ave, Portland, Maine 04101
Voice: 207-871-2150 Fax: 207-871-6501 Email: drummj@mail.mmc.org


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

Date: 18 Dec 1997 15:04:44 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What kind of machine wouldn't support FLOCK?
Message-Id: <67be2c$b4t$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, syarbrou@ais.net (Steve) writes:
:I have done extensive testing of flock on unix systems anyways and
:several systems have it, but only Linux truely seems to support it.
:All the other flavors of UNIX accept the command but do not work.

I cannot contain my disbelief: what was your test?  What you're saying
is exceedingly scary, and to the best of my occasionally splotchy
memory, contrary to my own empirical checks.  You should look through
/usr/src/perl/pp_sys.c for the contortions we go through to make this
work supporting the system calls of flock, fcntl, or lockf.  I believe
that the current version of Perl works on virtually all systems vaguely
programmer-friendly, and many that aren't.

Here's the Win32 code from /usr/src/perl/win32/win32.c, line #1329:

    DllExport int
    win32_flock(int fd, int oper)
    {
	if (!IsWinNT()) {
	    croak("flock() unimplemented on this platform");
	    return -1;
	}
	return pIOSubSystem->pfnflock(fd, oper);
    }

Note that it's not too happy about non-NT Win32 systems.
In /CPAN/ports/nt/winNT/FAQ/Perl_for_Win32_FAQ.txt, we find:

  - Some functions that work on Windows NT reportedly do not work 
    or are buggy on Windows 95.  An example is flock().

VMS seems to suffer here, since /usr/src/perl/vms/perlvms.pod says:

    The following functions were not implemented in the VMS port, 
    and calling them produces a fatal error (usually) or 
    undefined behavior (rarely, we hope):

	chroot, dbmclose, dbmopen, fcntl, flock,

As does Plan9, which has this in /usr/src/perl/plan9/config.plan9:

    #undef HAS_FLOCK         /**/

Whereas in /usr/src/perl/os2/os2.c we find the mysterious
reference to USE_PERL_FLOCK, but it appears to support it
just fine:

    int 
    my_flock(int handle, int op)
    {
      FILELOCK      rNull, rFull;
      ULONG         timeout, handle_type, flag_word;
      APIRET        rc;
      int           blocking, shared;
      static int    use_my = -1;

      if (use_my == -1) {
	char *s = getenv("USE_PERL_FLOCK");
	if (s)
	    use_my = atoi(s);
	else 
	    use_my = 1;
      }
      if (!(_emx_env & 0x200) || !use_my) 
	return flock(handle, op);   /* Delegate to EMX. */
      
      .......

You can probably look around in /CPAN/ports/ for other exceptions 
or issues.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Oh, I'm totally outrageous--I just never seem to inspire any outrage.  :-)"
    	--Larry Wall


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

Date: 18 Dec 1997 13:59:18 GMT
From: "Bruno Prior" <bruno@prior.ftech.co.uk>
Subject: Why can't I open with Perl5 dbm's created in Perl4?
Message-Id: <01bd0bbd$44e31860$0201a8c0@prior.ftech.co.uk>

I don't seem to be able to read or write dbm files in Perl5
that I created with Perl4. I have tried both dbmopen and
tie, but although they work fine with files created under
Perl5, I can't get at the old ones. I have tried using all
the different DBM modules with tie, but none of them work.
The old files are .dir/.pag pairs, which is what SDBM_File
creates, so I guess that's the closest, but it doesn't work
any better than the others. No error message is returned.

I'm using RedHat 4.1 Linux (kernel version 2.0.27), on a
dual Pentium Pro. I've got libgdbm in /usr/lib and the perl
DBM modules in /usr/lib/perl5, so I can't think that
anything's missing.

I'm pretty new to Perl5 (I've been putting off updating
precisely because of this problem). I'm probably missing
out something obvious. Has anyone got any ideas what it
might be.

Cheers,


Bruno Prior			bruno@prior.ftech.co.uk


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

Date: Thu, 18 Dec 1997 08:22:06 -0500
From: "Lewis X. Liu" <lxliu@lucent.com>
Subject: Re: Win32 Perl with MS Access
Message-Id: <67b80g$491@nntpb.cb.lucent.com>


Ray Ho wrote in message <676l5l$qn0$1@nclient5-gui.server.virgin.net>...
>
>Does anyone know how to access a MS Access database using Win32
>version of Perl?  What modules, sample codes will be much appreciated.


Why don't you try the WIN32::ODBC module.  More information about it can be
found http://www.roth.net/odbc/odbcfaq.htm.  Good Luck!

        ... Lewis




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

Date: 18 Dec 1997 11:35:43 GMT
From: gundlach@informatik.uni-dortmund.de (Patrick Gundlach)
Subject: xbase Problems
Message-Id: <67b1qf$8da$1@fbi-news.informatik.uni-dortmund.de>


Hi there,

I've got the following problem:

#!/usr/bin/perl
#
# RELEASE 4 (rename to xbase.pm and install along with perl libraries)
#
# xbase.pm is a perl module to access xbase files with simple IDX indexes.
# at the moment only read access to the files are provided by this package
# Writing is tougher with IDX updates etc and is being worked on. Since the
# read functionality is useful in itself this version is being released.
#
# This is an attempt to use the object oriented features of perl 5. I would 
# like feedback from the experts on this implementation. 
#
#    Copyright (c) 1995 Pratap Pereira. All rights reserved.
#    This program is free software; you can redistribute it and/or
#    modify it under the same terms as Perl itself.
#
#    pereira@ee.eng.ohio-state.edu
#
#
# Original perl 4 script done in March 1994
# Perl 5 module done in February 1995
#
# RELEASE 2 was first public release now called xbase12.pm
# RELEASE 3 was done 6/22/95 called xbase13.pm
#    Fixed problem with GO_PREV & GO_NEXT after SEEK.
#    Fixed problem with parsing headers of dbfs with record length > 255.
#    Added Memo file support.
# RELEASE 4 was done 9/29/95
#	 Fixed problem with certain IDX failing completely, was a stupid
#	 indexing mistake.
#
# Brief Usage: 
# 
# use xbase;
# 
# $dbfhandle= new xbase;
#       
# open_dbf($dbfhandle,DBF_NAME, [IDX_NAME]) where IDX_NAME is optional
#     * to open the database with the specified handle.
# dbf_type($dbfhandle)
#     * returns a string telling you if it is DBF3, DBF4 FOX etc...
# last_update($dbfhandle)
#     * returns date string when the DBF was last updated.
# lastrec($dbfhandle)
#     * returns record number of last record in file.
# dbf_stat($dbfhandle)
#     * Mnemonic to xbase display status/structure prints the structure
#       of the underlying database. Field names etc...
# idx_stat($dbfhandle)
#     * Prints the associated IDX details.
# go_top($dbfhandle)
#     * GO TOP of database. Physical top of DBF if no IDX else first record
#       in IDX order.


---


#!/usr/bin/perl 
use xbase;

$dbfhandle=new xbase;
open_dbf($dbfhandle, "plz-nrw.dbf");
print dbf_type($dbfhandle);

---

patrick@deep:/home/patrick/prog/perl/dbase > abfrage

Undefined subroutine &main::open_dbf called at ./abfrage line 5. 
(this is the line with open_ ...)
      
xbase.ps is in:  /usr/lib/perl5/xbase.pm   
perl is in       /usr/bin/perl

perl *does* find the xbase.pm 

Does anybody knows what to do?

-- 
Patrick Gundlach

+-----------------------------------------------------------+
  P.Gundlach@bigfoot.com
  Gundlach@irb.informatik.uni-dortmund.de                 
+-----------------------------------------------------------+



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

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

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