[9297] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2891 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 17 12:17:28 1998

Date: Wed, 17 Jun 98 09:00:31 -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           Wed, 17 Jun 1998     Volume: 8 Number: 2891

Today's topics:
        2 questions about lists <alex@kawo2.rwth-aachen.de>
    Re: 2 questions about lists <jdporter@min.net>
    Re: 2 questions about lists (Michael J Gebis)
    Re: 2 questions about lists <quednauf@nortel.co.uk>
        Array Combinations Question zucker@my-dejanews.com
    Re: Can't use subscript on split - what split? (Peter Williams)
    Re: Can't use subscript on split - what split? <aqumsieh@matrox.com>
        Cgi script to pass params to socket <paraicoc@aldiscon.ie>
        Copying files across NT servers nick_darby@my-dejanews.com
        Copying files across NT servers nick_darby@my-dejanews.com
    Re: Copying files across NT servers <bowlin@sirius.com>
        Copying files in perl across NT servers nick_darby@my-dejanews.com
        Development / Test Environments <dnp@ams.org>
    Re: flock (Larry Rosler)
        generating sets from lists of lists (Joel Coltoff)
    Re: getting first letter of a string (Larry Rosler)
    Re: getting first letter of a string <quednauf@nortel.co.uk>
    Re: getting first letter of a string (Joel Coltoff)
    Re: Help with exiting a loop <tturton@cowboys.anet-dfw.com>
    Re: htpasswd in perl? <merlyn@stonehenge.com>
    Re: htpasswd in perl? (Joseph A. DiVerdi, Ph.D.)
        kinda like tail -f...? (John Chapin)
    Re: More efficient search - binary search?? (Matt Knecht)
    Re: More efficient search - binary search?? (Abigail)
        NT CGI shell execution gfarris@my-dejanews.com
        perl - win NT CGI followup <edgar@sbrt.com>
    Re: Perl and Netware and Linux. . .oh my!! (Chris J [#6])
        Perl CGI NT 4.0 follow up <edgar@sbrt.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Jun 1998 17:13:37 +0200
From: "Alex Farber" <alex@kawo2.rwth-aachen.de>
Subject: 2 questions about lists
Message-Id: <6m8m8u$ir$1@nets3.rz.RWTH-Aachen.DE>

Here they are:

1) Is there (could not find in Camel book yet) some single 
operator to check if some element is contained in an array?

I currently do with a loop:

foreach $elem (@list)
{
    last if ($str eq $elem);
}

2) what happens if i do a foreach()-loop on some @list
and the push smth in that list IN THIS LOOP ? Like:

foreach $elem (@list)
{
    push @list, 'xxx' if ...
}

3) And a bonus question: which perl indentation modes for
emacs are there and where to get them (couldn't find them yet) ?

Thank you very much!
Alex




-- 
russkaya literatura v ------ http://www.simplex.ru/lit.html
internete http://www.friends-partners.org/~afarber/lit.html
java preferans ------------ http://www.simplex.ru/pref.html
besplatnye kommercheskie ob'yavleniya http://www.simplex.ru




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

Date: Wed, 17 Jun 1998 15:44:05 GMT
From: John Porter <jdporter@min.net>
Subject: Re: 2 questions about lists
Message-Id: <3587E607.5EBD@min.net>

Alex Farber wrote:
> 
> 1) Is there (could not find in Camel book yet) some single
> operator to check if some element is contained in an array?

No.  But as you can see, it's easy to do (and TIMTOWTDI).
And if you do it a lot, you can put it in a subroutine.


> 2) what happens if i do a foreach()-loop on some @list
> and the push smth in that list IN THIS LOOP ? Like:

What, are you afraid your computer might explode if you try it?

:-)

-- 
John Porter


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

Date: 17 Jun 1998 15:47:28 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: 2 questions about lists
Message-Id: <6m8oeg$sh4@mozo.cc.purdue.edu>

"Alex Farber" <alex@kawo2.rwth-aachen.de> writes:

}1) Is there (could not find in Camel book yet) some single 
}operator to check if some element is contained in an array?

Oh man.  Go to www.dejanews.com, and look for a thread entitled
something like "Why is there no 'in' operator in perl?"  You can look
for a post by me, as I answered with my usual brilliance.  And you can
look for replies to me, as people pointed out more efficient methods.

}2) what happens if i do a foreach()-loop on some @list
}and the push smth in that list IN THIS LOOP ? Like:

Off the top of my head, I'm not sure.  When you get your copy of perl
working, you should be able to try it out.  Also, I'm 99% sure
that this is in the FAQ.  (So there's a 1% chance it's not.  Read the
FAQ and show me up!  I dare ya!  Read it.  Read it.  Read it!)

}3) And a bonus question: which perl indentation modes for
}emacs are there and where to get them (couldn't find them yet) ?

Cperl mode is where it's at.  It's almost impossible to not find it,
but you can go to dejanews and type in "Ilya" and "perl" and "emacs"
to get even more information.


-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 17 Jun 1998 16:49:02 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: 2 questions about lists
Message-Id: <3587E56E.263DC22@nortel.co.uk>

Alex Farber wrote:
 
> 2) what happens if i do a foreach()-loop on some @list
> and the push smth in that list IN THIS LOOP ? Like:
> 
> foreach $elem (@list)
> {
>     push @list, 'xxx' if ...
> }
> 
Why don't you just try it out?

@elements = ('1', '2');
foreach $elem(@elements) {
 $sense = $elem+1;
 push (@elements, $sense);
 print $elem."\n";
}

Gives me:

1
2
2
3
3
4
4
5
5
6
6
 .
 .

Not quite what I expected, but it is one of many ways to create an endless loop.
-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Wed, 17 Jun 1998 15:22:22 GMT
From: zucker@my-dejanews.com
Subject: Array Combinations Question
Message-Id: <6m8mve$h2h$1@nnrp1.dejanews.com>

Hello,

how can I get all of the combinations of a dynamic multidiminsional array?

for example:

during program run:

$array[0][0] contains "hello"
$array[0][1] contains "there"
$array[1][0] contains "jupiter"
$array[1][1] contains "saturn"
$array[1][2] contains "mars"
$array[2][0] contains "happy"

I need the combinations:

hello jupiter happy
hello saturn happy
hello mars happy
there jupiter happy
there saturn happy
there mars happy

and so on, up to n elements ($array[n][n])

Thanks in Advance

Robert.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 17 Jun 1998 14:54:58 GMT
From: williams@eisws25.jpl.nasa.gov (Peter Williams)
Subject: Re: Can't use subscript on split - what split?
Message-Id: <slrn6ofm60.glh.williams@eisws25.jpl.nasa.gov>

That's because

	qw(JAN FEB)

(from the perlop manpage) "is exactly equivalent to":

	split(' ', 'JAN FEB')

Therefore, it treats everything inside the qw() as a single-quoted
string, and splits on that string.   This is similar to:

	split(/\s+/, 'JAN FEB')

except that the split(' ',STRING) -- which is a special case of
split, remember -- removes leading whitespace as well.

Peter Williams <peter.williams@jpl.nasa.gov>

--------------------- TYPICAL ROOT .cshrc FILE: ---------------------- 
TECHNICAL THUG:  Longer than eight kilobytes.  Sources the output of a
  perl script, rewrites itself.
  -- Stephan Zielinski, "KNOW YOUR UNIX SYSTEM ADMINISTRATOR"

On 16 Jun 1998 21:14:56 GMT, Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
>Encountered this when I forgot a pair of parentheses (abbreviated example):
>
>	print qw(JAN FEB)[1];
>
>Can't use subscript on split at - line 1, near "1]"
>
>I would love to know how Perl interpreted this as a split...
>
>-- 
>This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
>brain on news.  Any questions?   |  (psf@euclid.jpl.nasa.gov)
>
>Disclaimer:  These comments are the personal opinions of the author, and 
>have not been adopted, authorized, ratified, or approved by JPL.


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

Date: Wed, 17 Jun 1998 10:15:34 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Can't use subscript on split - what split?
Message-Id: <3587CF86.ECCF1BDB@matrox.com>

Peter Scott wrote:

> Encountered this when I forgot a pair of parentheses (abbreviated example):
>
>         print qw(JAN FEB)[1];
>
> Can't use subscript on split at - line 1, near "1]"
>
> I would love to know how Perl interpreted this as a split...
>

Perhaps if you read the documentation you would know ...

>From perldoc perlop:

     qw/STRING/
             Returns a list of the words extracted out of STRING,
             using embedded whitespace as the word delimiters.
             It is exactly equivalent to

                 split(' ', q/STRING/);


> --
> This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
> brain on news.  Any questions?   |  (psf@euclid.jpl.nasa.gov)
>
> Disclaimer:  These comments are the personal opinions of the author, and
> have not been adopted, authorized, ratified, or approved by JPL.



--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)





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

Date: Wed, 17 Jun 1998 16:27:39 +0100
From: Paraic O'Ceallaigh <paraicoc@aldiscon.ie>
Subject: Cgi script to pass params to socket
Message-Id: <3587E06B.B239998A@aldiscon.ie>

Hi,
I want to write a script to pass parameters from a html form
to a  daemon listening on a port (which then executes those
params).
I have done some file and text processing with perl4 but have no
clue as to where to start with the above in perl5 and its modules.
Any pointers appreciated.
-- 
Paraic O Ceallaigh       mailto:paraicoc@aldiscon.ie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"You will know the truth and the truth will set you
free..but first it will piss you off!"  - Anonymous
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
(Ph) +353 1 819 3514    mailto:swipe@redbrick.dcu.ie
_____________________________________________________


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

Date: Wed, 17 Jun 1998 14:12:07 GMT
From: nick_darby@my-dejanews.com
Subject: Copying files across NT servers
Message-Id: <6m8irn$bm3$1@nnrp1.dejanews.com>

I've got a file on one NT server that I want to copy to another server.

I tried directing the output to the destination ie the code on 'machine 1' to
get the file to 'machine 2' used UNC, with suitable values for machine2 and
share_dir
$FILE_DEST="////machine2//share_dir";
OPEN(DATA,">$FILE_DEST");
 ....

When this didn't work, I tried to use the system command to copy the file
from one server to another. I could COPY within the machine1, and I could do
a range of other os commands (such as 'net use' to set up a network drive to
machine2) but it would not copy a file from machine1 to machine2.

Any suggestions gratefully received.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 17 Jun 1998 14:12:05 GMT
From: nick_darby@my-dejanews.com
Subject: Copying files across NT servers
Message-Id: <6m8irk$bm2$1@nnrp1.dejanews.com>

I've got a file on one NT server that I want to copy to another server.

I tried directing the output to the destination ie the code on 'machine 1' to
get the file to 'machine 2' used UNC, with suitable values for machine2 and
share_dir
$FILE_DEST="////machine2//share_dir";
OPEN(DATA,">$FILE_DEST");
 ....

When this didn't work, I tried to use the system command to copy the file
from one server to another. I could COPY within the machine1, and I could do
a range of other os commands (such as 'net use' to set up a network drive to
machine2) but it would not copy a file from machine1 to machine2.

Any suggestions gratefully received.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 17 Jun 1998 07:53:00 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: nick_darby@my-dejanews.com
Subject: Re: Copying files across NT servers
Message-Id: <3587D84C.AEDEE1F3@sirius.com>

nick_darby@my-dejanews.com wrote:
> 
> I've got a file on one NT server that I want to copy to another server.
> 
> I tried directing the output to the destination ie the code on 'machine 1' to
> get the file to 'machine 2' used UNC, with suitable values for machine2 and
> share_dir
> $FILE_DEST="////machine2//share_dir";
> OPEN(DATA,">$FILE_DEST");
> ....

I have one suggestion: Don't try to escape the forward slash character.
And especially, don't try to use forword slash as an escape character.

I suggest trying one of these:

   $FILE_DEST="/machine2/share_dir";  
   $FILE_DEST="//machine2/share_dir";

unless NT really wants to see four slashes and then two.

Good luck, -- Jim Bowlin


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

Date: Wed, 17 Jun 1998 14:13:26 GMT
From: nick_darby@my-dejanews.com
Subject: Copying files in perl across NT servers
Message-Id: <6m8iu6$bme$1@nnrp1.dejanews.com>

I've got a file on one NT server that I want to copy to another server.

I tried directing the output to the destination ie the code on 'machine 1' to
get the file to 'machine 2' used UNC, with suitable values for machine2 and
share_dir
$FILE_DEST="////machine2//share_dir";
OPEN(DATA,">$FILE_DEST");
 ....

When this didn't work, I tried to use the system command to copy the file
from one server to another. I could COPY within the machine1, and I could do
a range of other os commands (such as 'net use' to set up a network drive to
machine2) but it would not copy a file from machine1 to machine2.

Any suggestions gratefully received.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 17 Jun 1998 10:44:23 -0400
From: Daniel Pelton <dnp@ams.org>
Subject: Development / Test Environments
Message-Id: <3587D647.6046D381@ams.org>

We are going to set up a development and test environment
on the same machine (unix) and a production environment 
another machine.  We are going to put out perl scripts under 
version control using RCS and CVS.

Has anyone else had any experience doing this and how should I 
handle absolute paths in Perl CGIs and html pages? I was thinking
of created a configuration module for the perl scripts which would
contain the absolute paths. Each environment would contain it's
own copy of this file.  I was going to use the PERL5LIB environment
variable to point to the directory containing the configuration module.
PERL5LIB would be different for each environment.  I am not sure
how to set this environment variable when using the different 
environments thought the web.

The perl scripts contain absolute directory references like:
	$CFG_FILE="/dsk1/web/post/etc/post_req.cfg";
	$cgi_prog ="http://axp16.ams.org/cgi-bin/post/post_new.pl";
	print "<BASE href=\"http://axp16.ams.org/post/home.html\">\n";
	$input{BACK_URL}="axp16.ams.org/cgi-bin/post/post_new.pl";

The html files also contain absolute references like:
	HREF="JavaScript:loadframes
	('http://axp16.ams.org/cgi-bin/post/nav_new.pl
	?PUB=bull&TARGET=LEFT',

'http://axp16.ams.org/cgi-bin/post/nav_new.pl?PUB=bull&TARGET=RIGHT')">B


thanks,
Dan Pelton
dnp@ams.org


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

Date: Wed, 17 Jun 1998 07:04:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: flock
Message-Id: <MPG.ff16cd8342ee2b09896bf@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6lng0m$518$4@csnews.cs.colorado.edu>, tchrist@mox.perl.com 
says...
 ..
> One point I forgot to mention in this because it didn't
> occur to me at the time is that simply doing the rename before
> the close is no help because then the wrong version is locked.

On certain primitive (i.e., non-Unix) operating systems currently in wide 
use, neither 'rename' nor 'unlink' will succeeed on an open file.  And we 
*are* interested in portability, no?

> Perhaps there's cause for a separate lockfile afterall.

Until there is an atomic 'close-and-rename' function in all these OSs 
(i.e., never), perhaps it's unavoidable.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 17 Jun 1998 14:10:51 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: generating sets from lists of lists
Message-Id: <6m8ioi$sf7@netaxs.com>

I'm looking for a clever solution to the following problem. I've
got a small number of lists of lists. I want to generate all the
combinations of sets that can be formed from these lists. The problem
is that I don't know until all the data has been generated how many
lists there will be. This is usually a number between 4 and 10 and
I suppose I could write a separate case for each. In the code below what
would happen if I added a list of control chars? I don't really want to
add another foreach(). Also, the data is generated on the fly so
I end up the array @chars. Perhaps there is a better way to do this
as well. That however is only an issue if it impacts the rest of
the problem.

    @numbers = (['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']);
    @letters = (['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']);
    @symbols = (['!', '@', '#'], ['$', '%', '^'], ['&', '*', '(']);
    push(@chars, [@numbers], [@letters], [@symbols]);
    foreach $number (@numbers) {
	foreach $letter (@letters) {
	    foreach $symbol (@symbols) {
		print "@$number -- @$letter -- @$symbol\n";
	    }
	}
    }

Thanks for your help and advice.

-- 
Joel Coltoff

I'd explain it, but there's a lot of math. -- Calvin


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

Date: Wed, 17 Jun 1998 07:03:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: getting first letter of a string
Message-Id: <MPG.ff16c9c6da0f49e9896be@nntp.hpl.hp.com>

In article <6m7mv2$moq@mozo.cc.purdue.edu>, gebis@albrecht.ecn.purdue.edu 
says...
> rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
> 
> }Ritche Macalaguim <ritche@san.rr.com> wrote:
> }> How can I get the first letter of a string in Perl?
> 
> }($first) = $string =~ /([a-z])/i;
> 
> };-)
> 
> You fascist american umlaut-ignoring, accent-hating, not-to-mention
> that-funny-german-B-and-that-french-c-with-a-tail-bigoted pig!
> 
> -- 
> Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net

Right, and Mike Stok gave the 'right' answer.  However, for what comfort 
it's worth, you have not really ignored that funny-german-B (ess-tset, 
often written nowadays simply as 'ss').  Like 'ss' in English, it cannot 
occur at the beginning of a word.  Of course, no one said that the 
'string' in this question had to begin with a word. :-)

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 17 Jun 1998 15:39:19 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: getting first letter of a string
Message-Id: <3587D517.B43DFEDC@nortel.co.uk>

Larry Rosler wrote:

> ...However, for what comfort
> it's worth, you have not really ignored that funny-german-B (ess-tset,
> often written nowadays simply as 'ss')...

ARGH! Keep the new German f..ck.. cr..p sh..te 'Rechtschreibreform' away!!!
Oh well, English is taking over the world...

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Wed, 17 Jun 1998 15:05:00 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: getting first letter of a string
Message-Id: <6m8lu2$489@netaxs.com>

In article <3587D517.B43DFEDC@nortel.co.uk>,
F.Quednau <quednauf@nortel.co.uk> wrote:
>
>ARGH! Keep the new German f..ck.. cr..p sh..te 'Rechtschreibreform' away!!!
>Oh well, English is taking over the world...

You may feel this way but that is not my weltanschauung. Now
back to work, my raison d'etre. ;-) ;-)

-- 
Joel Coltoff

I'd explain it, but there's a lot of math. -- Calvin


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

Date: Wed, 17 Jun 1998 08:42:04 -0500
From: Tom Turton <tturton@cowboys.anet-dfw.com>
To: julih@earthlink.net
Subject: Re: Help with exiting a loop
Message-Id: <3587C7AB.D30E7DDD@cowboys.anet-dfw.com>

This is a multi-part message in MIME format.
--------------C2907AFB3DD0D89A28C31809
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit





--------------C2907AFB3DD0D89A28C31809
Content-Type: text/plain; charset=us-ascii; name="junk.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="junk.txt"

Try this:

unless (open(LIST, "list.pl")) { 
    die ("Can't open list\n"); 
} 
$rep_name = "SamV";
while (<LIST>)   {
    if ($_ =~ "$rep_name")	 {					     
#   only use $rep_name to "match" strings; modify the actual input value "$_"
	  substr($_,3) =~ tr/a-z/A-Z/;		
        exit;   
    }else{	     
	  substr($_,0) =~ tr/a-z/A-Z/;			
        substr($_,1) =~ tr/A-Z/a-z/;	
#  remove the exit that was here; don't exit until you match $rep_name
    }
}

---Tom Turton

>From - Wed Jun 17 08:13:54 1998
From: Juli@my-dejanews.com
Newsgroups: comp.lang.perl.misc
Subject: Help with exiting a loop
Date: Wed, 17 Jun 1998 01:32:01 GMT

unless (open(LIST, "list.pl")) { 
    die ("Can't open list\n"); 
} 
$rep_name = "SamV";
while ($line =<LIST>)   {
    if ($line =~ "$rep_name")	 {					     
	  substr($rep_name,3) =~ tr/a-z/A-Z/;		
        exit;   
    }else{	     
	  substr($rep_name,0) =~ tr/a-z/A-Z/;			
        substr($rep_name,1) =~ tr/A-Z/a-z/;	
        exit;		     
    }
}

 Basically what I'm trying to do is read a list, and compare it to
another value. If it is the same, capitalize  the whole value. If is
different, then capitalize the first value. My problem is I can only exit the
program in one of the if sections, not both.  What I want to do is as soon as
it finds what it is looking for to exit, instead it keeps going through the
loop.  Please help, I'm a little new at this. My email address is
julih@earthlink.net


--------------C2907AFB3DD0D89A28C31809--



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

Date: Wed, 17 Jun 1998 13:47:49 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: htpasswd in perl?
Message-Id: <8clnqwgmx2.fsf@gadget.cscaper.com>

>>>>> "Douglas" == Douglas Potts <doug@zmark.com> writes:

Douglas> Need help with a script I am working on that will create
Douglas> passwords the same as htpasswd executable.

use HTTPD::UserAdmin; # found in the CPAN

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 76 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@teleport.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 Jun 1998 09:41:01 -0600
From: diverdi@XTRsystems.com (Joseph A. DiVerdi, Ph.D.)
Subject: Re: htpasswd in perl?
Message-Id: <diverdi-1706980941020001@algae2.verinet.com>

In article <8clnqwgmx2.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:

> Need help with a script I am working on that will create
> passwords the same as htpasswd executable.

Randal,

Here is a complete code snippit that shows you how to do it and actually
works. The script is executed as follows:

encrypt plain_text_password [user_specified_salt]

Obviously, I have called the script 'encrypt'. You can have the script
generate its own salt or you can enter your own value. It prints the
encrypted value on the next line.

The code follows:

#!/usr/local/bin/perl
srand(time ^ ($$ + ($$ <<15)));
my @chars = ('0'..'9','a'..'z','A'..'Z');
my $salt = $ARGV[1];
$salt = $chars[int rand @chars] . $chars[int rand @chars] if $ARGV[1] eq "";
print crypt($ARGV[0], $salt), "\n";
exit;

Here is some sample output:

encrypt hemorrhoid
iqTvqxBv1HWUE

encrypt hemorrhoid
fNC.CAt5FsPQM

encrypt hemorrhoid
1tmsffosY4nSU

encrypt hemorrhoid
UuFE0fkVo0wLo

As you can see, the use of a random salt results in different encrypted
passwords although they all correspond to the plain text.

Now, if you provide a salt the following is obtained:

encrypt hemorrhoid 8J
8JYItIEP98yXo

encrypt hemorrhoid 8J
8JYItIEP98yXo

encrypt hemorrhoid 8J
8JYItIEP98yXo

I hope that this helps.

passme

-- 
Joseph A. DiVerdi, Ph.D.                          970.221.3982 (voice)    
diverdi@XTRrsystems.com (email)                   970.224.3723 (fax)
http://www.XTRsystems.com
%PGPKey=('BB1469AB',[1024,'24DA 2D00 ABB0 D26F 4E14 56C9 0CEF 1053 BB14 69AB'])


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

Date: 17 Jun 1998 11:47:58 -0400
From: jchapin@panix.com (John Chapin)
Subject: kinda like tail -f...?
Message-Id: <6m8ofe$2j5@panix.com>
Keywords: open() perl tail -f


  I'm trying to read an application's log file as it is written,
without reading any "old" lines which were written before my
program started.

  #!/usr/bin/perl -w
  open(LOG, "/usr/bin/tail -0f /the/application/log.txt |");
  while (<LOG>) {
    # my code here...
  };

  I a simple way, the above mostly works...  the problem is that
the "tail -0f" doesn't really work: it allways gives me the last 10
lines, and then behaves as expected -- as new lines are written, 
to log.txt, my perl reads them from LOG.  (This is certainly a
problem with my Solaris "tail", and not really a perl issue at
all...)  (And I've discovered that using "tail -1f" lessens the
problem somewhat, but does not eliminate it.)

  But Is There A Better Way...?  How about using a fifo?  Well,
says I, I would either have to convince the application to write
directly to a mutually agreeable fifo, which could be a problem
if my perl script reading the fifo should fall down somehow.  Or
I could FIRST make a script which continously reads the log.txt
and writes to a fifo, and a SECOND script which looks like the
above code, but does the open() on the fifo instead...

  I suppose what I'm really asking for is how to get an open()
to ignore the EOF -- so it behaves like a "tail -f", and once
I can do that, to open() it at the current EOF so it will only
read _new_lines_of_data_written_after_the_open()_is_called...

  any ideers...?   thanks -- John Chapin  jchapin@panix.com


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

Date: Wed, 17 Jun 1998 14:55:48 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: More efficient search - binary search??
Message-Id: <UNQh1.193$Cb1.449590@news2.voicenet.com>

Mark-Jason Dominus <mjd@op.net> wrote:
>
>In article <IJIh1.28$qF2.150812@news3.voicenet.com>,
>Matt Knecht <hex@voicenet.com> wrote:
>>True enough, but sometimes there exists the need to search an array.  I
>>imagine that's at least part of the reason grep exists.  
>
>grep usually makes more sense when you are expecting multiple matches.

Agreed!

>Typically:
>
>	@useful_items = grep {is_useful $_} @items;

Agreed, again.

>Using grep to detect the presence of an item in a list is usually wasteful.

Usually, but I find it much easier to read (and write) a grep instead of
a for loop if I only need to check an array once for an element.  If the
array is reasonably short, there isn't much of a speed difference, and
if the code is only going to do it once, I prefer the readability to the
 .0001 seconds of computing time to compare those extra elements after
the match.

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: 17 Jun 1998 15:53:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: More efficient search - binary search??
Message-Id: <6m8oq9$2jb$2@client3.news.psi.net>

Mark-Jason Dominus (mjd@op.net) wrote on MDCCLI September MCMXCIII in
<URL: news:6m7qh3$m69$1@monet.op.net>:
++ 
++ In article <IJIh1.28$qF2.150812@news3.voicenet.com>,
++ Matt Knecht <hex@voicenet.com> wrote:
++ >True enough, but sometimes there exists the need to search an array.  I
++ >imagine that's at least part of the reason grep exists.  
++ 
++ grep usually makes more sense when you are expecting multiple matches.
++ 
++ Typically:
++ 
++ 	@useful_items = grep {is_useful $_} @items;
++ 
++ Using grep to detect the presence of an item in a list is usually wasteful.


Besides, it's boring. Just use a regex if you're looking for an
exact match:

     {local $" = '|';
      $match = $item =~ /^(?:@{[map {"\Q$_"} @items]})$/;}



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Wed, 17 Jun 1998 14:22:30 GMT
From: gfarris@my-dejanews.com
Subject: NT CGI shell execution
Message-Id: <6m8jf6$ckj$1@nnrp1.dejanews.com>

I'm trying to execute a shell string from a CGI,
eg. $a = `isql -U username -P password -i script.sql`

This process works when I run the perl script interactively, but not through
Internet Information Server (4.0).  The perl script executes with the
exception of the shell command.

I'm not sure what environment, or IIS setting I need to change in order to fix
this problem.

Any help would be greatly appreciated.

Thanks

John

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 17 Jun 1998 12:47:27 -0300
From: Edgar <edgar@sbrt.com>
Subject: perl - win NT CGI followup
Message-Id: <3587E50F.8606082B@sbrt.com>

This is a follow up of my yesterday's posting. If anyone has experienced
anything of the sort, or has any clue as how to fix this problem, please
drop me a line.


Problem:

When a form calls a perl script in a directory where the scripts reside,
the script that gets executed is ALWAIS the first one on the directory.
That happens no matter what script name the form requires.

Setup:
Win NT 4.0 running IIS
Perl version --------------

I have executed the self extracting perl .exe under InetPub\scripts\perl

Then modified the Win NT registry as explained on the IIS documentation
to make the .pl extension recognizable for the CGI interface and so on.

Real directory structure as follows:

dat
  web
     rx3                 -> read permissions
         cgi-loc       ->execute permissions
             program1.pl
             program2.pl
             program3.pl
         dir 1
         dir 2
         secure
             form1.htm

Then rx3 is set also as a virtual directory with read permissions, and
cgi-loc is set as cgi-local with execute permissions.


I have enabled the "examine directories" box on IIS so that one can get
to rx3 and traverse down.


Procedure:
I open with Netscape 4.02 from1.htm under directory secure, fill it up
and click send, which uses the post method to call program1.pl
The post call in the form1.htm goes like this:
http://server1/cgi-local/program1.pl

(NOTE: server1 is the internet domain name as it appears on the DNS page
of the TCP/IP property sheet. The machine is NOT currently hooked to the
internet, I am only running locally. Also when I start the browser and
type http://server1  it loads the IIS default page, menaing it is
recognizing server1 as a domain name.)

The script runs fine and produces output.
When I go to the form1.htm and change the post request to call let's say
program2.pl it just keeps executing program1.pl
Furthermore if I change the call to http://server1/cgi-local/anything.pl
it STILL OUTPUTS the stuff from program1.pl
Now next step:
If I rename program3.pl to aa.pl and submit the form, I get the output
from program3.pl
My conclusion: I am always getting the output from the first program in
the cgi-local virtual directory, meaning the first in the ascending sort
order by name.


Please can I get a procedure to fix this ?

Thanks,  best regards.

Edgar.







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

Date: 17 Jun 1998 14:45:30 +0100
From: syscej@linux2.cms.shu.ac.uk (Chris J [#6])
Subject: Re: Perl and Netware and Linux. . .oh my!!
Message-Id: <6m8h9q$5m4@linux2.cms.shu.ac.uk>

The kernel supports Netware...just compile IPX into the kernel, and you will
probably also need to check support for other areas as well.If you read the
'help' of the IPX option, then most of the links and info you need to look
at is there :)

There's an IPX-HOWTO available on sunsite that may help you with this.

Chris...

In article <35800151.892C8A8C@mail.shebang.net>,
Robert Eric Pearse  <pearse@mail.shebang.net> wrote:
>Hey all,
>
>I've got what I "think" is a unique problem. . .
>
>Problem: There is constant stream of doc's piling up on a Netware
>networked drive. I need to put them on a colocated Linux web server.
>Also, there is an Access 2.0 database sitting on the same drive that
>contains data about the docs. (I know, I know. . .but the office is
>still using Win3.X. . .my hands are tied!)
>
 ...[deletia]...
-- 
 @}--- Chris Johnson ~~~~~~~~~~~~~~~~|~~~~~~~~~ cjohnso0@pine.shu.ac.uk ---{@
    / When will we get the chance to |                                   \
   / be ourselves? When will the     |      Eat a pint of fish a day      \
  / labeling in society dissapear?   |                                     \


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

Date: Wed, 17 Jun 1998 12:24:53 -0300
From: Edgar <edgar@sbrt.com>
Subject: Perl CGI NT 4.0 follow up
Message-Id: <3587DFC4.D7775C5E@sbrt.com>

This is a follow up of my yesterday's posting.
If any one is experiencing something of the sort or anyone knows how to
fix the problem please help.

Problem:

When a form calls a perl script in a directory where the scripts reside,
the script that gets executed is ALWAIS the first one on the directory.
That happens no matter what script name the form requires.

Setup:
Win NT 4.0 running IIS
Perl version 5.004

I have executed the self extracting perl .exe under InetPub\scripts\perl

Then modified the Win NT registry as explained on the IIS documentation
to make the .pl extension recognizable for the CGI interface and so on.

Real directory structure as follows:

dat
  web
     rx3                 -> read permissions
         cgi-loc       ->execute permissions
             program1.pl
             program2.pl
             program3.pl
         dir 1
         dir 2
         secure
             form1.htm

Then rx3 is set also as a virtual directory with read permissions, and
cgi-loc is set as virtual directory cgi-local with execute permissions.


I have enabled the "examine directories" box on IIS so that one can get
to rx3 and traverse down.


Procedure:
I open with Netscape 4.02 from1.htm under directory secure, fill it up
and click send, which uses the post method to call program1.pl
The post call in the form1.htm goes like this:
http://server1/cgi-local/program1.pl

The script runs fine and produces output. (Note: sever1 is the ineternet
domain name, the machine is not currently connected to the internet. If
I just say http://server1 the browser brings me the default IIS home
page, meaning it is recognizing server1 as the internet domain.)

When I go to the form1.htm and change the post request to call let's say
program2.pl it just keeps executing program1.pl
Furthermore if I change the call to http://server1/cgi-local/anything.pl
it STILL OUTPUTS the stuff from program1.pl
Now next step:
If I rename program3.pl to aa.pl and submit the form, I get the output
from program3.pl
My conclusion: I am always getting the output from the first program in
the cgi-local virtual directory, meaning the first in the ascending sort
order by name.


Please can I get a procedure to fix this ?

Thanks,  best regards.

Edgar.







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

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

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