[13325] in Perl-Users-Digest
Perl-Users Digest, Issue: 735 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 7 22:07:40 1999
Date: Tue, 7 Sep 1999 19:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 7 Sep 1999 Volume: 9 Number: 735
Today's topics:
Accessing NT DB from Linux Perl <mflora@fmca.com>
Re: APi519e.exe and Win98??? <cook@mediaone.net>
Re: Automating Secure Copy using Perl <blanders@gandalf.bluecoat93.net>
Re: Counting duplicate list elements in Perl <uri@sysarch.com>
Re: eof() (Mike Stok)
help,Newbie save a file (Randy)
Re: help,Newbie save a file <makkulka@cisco.com>
How to compare references? <johnlin@chttl.com.tw>
Re: Inserting data into a file <makkulka@cisco.com>
Re: Inserting data into a file (Larry Rosler)
Installing ActiveState 51X and PPM nick@xyvision.com
Re: integer mistery (Larry Rosler)
Re: integer mistery (Larry Rosler)
Re: large dataset problem <bigsleep@dircon.co.uk>
modules in home dir (DynaLoader.pm) <kims@emmerce.com.au>
Re: Multithreaded client/server in Perl <charlie@mother.com>
Re: mysql interview <borg@imaginary.com>
opening files/secure server <prfctbt@cris.com>
Password Problem <anmolnar@videon.wave.ca>
Re: Password Problem <anmolnar@videon.wave.ca>
Re: Pattern Matching Question (elephant)
Re: Programmer's Editor (Randal L. Schwartz)
Re: Programmer's Editor (elephant)
Question about a hash <ilya@speakeasy.org>
Re: reading special character(? EOF or NULL?) from Sock (Gilly)
Referencing another server? <zomzomNOkmSPAM@hotmail.com>
very simple question. <zhuang@ic.sunysb.edu>
Re: very simple question. <anmolnar@videon.wave.ca>
Re: very simple question. (Larry Rosler)
What the flock?!? (Bill Moseley)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 7 Sep 1999 21:34:31 -0400
From: "Mike Flora" <mflora@fmca.com>
Subject: Accessing NT DB from Linux Perl
Message-Id: <37d5bd4f@news1.one.net>
Can anyone tell me:
1) If it is possible to access an NT MS SQL Server from a Linux box using
Perl?
2) If so, do I need special Linux drivers (if they exist)?
3) How to do it...
Thanks for any help or information you can pass my way.
Mike Flora
------------------------------
Date: Tue, 07 Sep 1999 19:17:34 -0400
From: edgar <cook@mediaone.net>
Subject: Re: APi519e.exe and Win98???
Message-Id: <37D59D0D.BA772C61@mediaone.net>
> <snip>
> > > Anybody have success with build 519 and Win98?
> > >
> > > Ray
Yes I have build 519 on win 98. It took aprox 15 min total time to install. I
have a pentium at 166Mhz with 128M. The installation was a new installation
because I had build 513 and had to uninstall it and clean up the registry a
little.
hth
-cookie
------------------------------
Date: 07 Sep 1999 19:28:48 -0400
From: Brian Landers <blanders@gandalf.bluecoat93.net>
Subject: Re: Automating Secure Copy using Perl
Message-Id: <m34sh65mj3.fsf@gandalf.bluecoat93.net>
> Would rsync (Andrew Tridgell's software) work over ssh?
Yes
------------------------------
Date: 07 Sep 1999 20:08:01 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Counting duplicate list elements in Perl
Message-Id: <x7btbenu3i.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@delanet.com> writes:
A> Matthew David Zimmerman (mdz4c@node5.unix.Virginia.EDU) wrote on MMCXCII
A> September MCMXCIII in <URL:news:7qk8bd$et8$1@murdoch.acc.Virginia.EDU>:
A> ~~ Uri Guttman <uri@sysarch.com> wrote:
A> ~~ >
A> ~~ >a little perl golf here
A> ~~ >
A> ~~ [snip]
A> ~~ >
A> ~~ >or as a one liner:
A> ~~ >
A> ~~ >perl -lne '$c{$_}++;END{print "$_,$c{$_}" for sort keys %c}'
A> ~~
A> ~~ perl -lne '$c{$_}++}{print "$_,$c{$_}" for sort keys %c'
A> perl -lne '$c{$_}++}{print"$_,$c{$_}"for sort keys%c'
in another thread i banned your }{ -n trick from perl golf. it is too
cute.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Tue, 07 Sep 1999 23:59:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: eof()
Message-Id: <uFhB3.792$U5.716176@typhoon1.austin.rr.com>
In article <37D51366.C459544E@cs.auc.dk>, Chen Li <erpeng@cs.auc.dk> wrote:
>Hi, all:
>
>How to exit when end of file. I read in two lines data file one by one.
>The last read will
>fetch only one line data. I tried until eof(FH), it does not work.
The <> operator will help you out in this situation. If FH is a file
handle which has been successfully opened for reading then this will read
one record at a time from the file handle until the file is all consumed:
while (<FH>) {
# $_ contains a record from FH, by default a record is a line
}
This is covered in the I/O Operators section of the perlop documentation,
or look for <> or the "diamond operator" in any reasonable perl book and
you should fing a more thorough explanation.
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
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Tue, 07 Sep 1999 23:16:56 GMT
From: randys@dowco.com (Randy)
Subject: help,Newbie save a file
Message-Id: <37d59bec.60106045@news.dowco.com>
Hello,
All I need to know is there an extention I have to put on the end of a
script file ?
i.e. hello_world.pl " does the " pl " have to be there of
something else.
thank you very much!
------------------------------
Date: Tue, 07 Sep 1999 16:53:06 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: help,Newbie save a file
Message-Id: <37D5A562.F3D7C5AF@cisco.com>
[ Randy wrote:
> All I need to know is there an extention I have to put on the end of a
> script file ?
> i.e. hello_world.pl " does the " pl " have to be there of
> something else.
The extension can be anything. It need not be "pl". In fact it can even
be ".html".
--
------------------------------
Date: Wed, 8 Sep 1999 09:46:01 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: How to compare references?
Message-Id: <7r4f0n$bkm@netnews.hinet.net>
Bill Moseley wrote
>John Lin wrote
>> @objects=($johnson,$mary,$tommy);
>> $reference=$johnson;
>> if(grep($reference,@objects)) {
>> print $reference->{name}," is my friend";
>> }
>
> $johnson is just some memory address. And it still doesn't work.
>
Actually, my pratical question is
"Then, how to compare references?" (it's not documented in perlref)
I guess
grep { $reference eq $_ } @objects
will work because it compares strings like "HASH(0xcb3d80)"
which is unique for each reference.
But I doubt whether this is the correct way to compare references.
Or we need another op, say "req", eq for references, to put here?
grep { $reference req $_ ) @objects
Thank you for your advices.
John Lin
------------------------------
Date: Tue, 07 Sep 1999 17:01:40 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Inserting data into a file
Message-Id: <37D5A764.215217D1@cisco.com>
[ Laurent Cordon wrote:
> I would like to insert data into my file as described below
> {snipp...}
> My problem is how to insert amerlino@afp.com at this position and
> not at the top nor bottom of the file
As you want to insert a line of text between two lines of text
you will have to start copying lines of text to a new file. Then
add your extra lines as required to the new file. Delete the old
file and then rename the new file as the older one.
--
------------------------------
Date: Tue, 7 Sep 1999 17:48:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Inserting data into a file
Message-Id: <MPG.123f524125aded77989f25@nntp.hpl.hp.com>
In article <37D57B8A.21C98773@afp.com> on Tue, 07 Sep 1999 22:54:35
+0200, Laurent Cordon <Laurent.Cordon@afp.com> says...
...
> My problem is how to insert amerlino@afp.com at this position and
> not at the top nor bottom of the file
perlfaq5: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of a
file?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 07 Sep 1999 23:16:11 GMT
From: nick@xyvision.com
Subject: Installing ActiveState 51X and PPM
Message-Id: <7r46bh$aqp$1@nnrp1.deja.com>
Hello all:
I am running NT4.0, Service Pack 5.
I am having a no doubt familiar, though not very discussed problem
installing ActiveState 515,6,7,, and 9!
While the install is configuring perl ("This may take a few minutes"),
the install crashes and Dr. Watson prints the log message about an app
error in _INS0432._MP.EXE, Exception: access violation, etc.
Well, perl is incompletely installed, but I can still run things after
doing some manual setup (i cannot however run uninstall).
Then, to install Tk, I attempt to use PPM, but it cannot find the
PPM_DAT file. I try the various hints lying about, to no avail.
here is the log of my attempts:
G:\Perl\site\lib>ppm genconfig > ppm.xml
G:\Perl\site\lib>ppm install Tk
Failed to load PPM_DAT file
Error installing package 'Tk': Could not locate a PPD file for package
Tk
G:\Perl\site\lib>ppm install
http://www.activestate.com/packages/zips/Tk.ppd
Failed to load PPM_DAT file
Error installing
package 'http://www.activestate.com/packages/zips/Tk.ppd': Coul
d not locate a PPD file for package
http://www.activestate.com/packages/zips/Tk.
ppd
G:\Perl\site\lib>ppm install http://www.activestate.com/packages/zips/Tk
Failed to load PPM_DAT file
Error installing package 'http://www.activestate.com/packages/zips/Tk':
Could no
t locate a PPD file for package
http://www.activestate.com/packages/zips/Tk
G:\Perl\site\lib>ppm install
http://www.activestate.com/packages/zips/Tk.zip
Failed to load PPM_DAT file
not well-formed at line 1, column 2, byte 2 at
g:/Perl/site/lib/XML/Parser.pm li
ne 153
G:\Perl\site\lib>
G:\Perl\site\lib>
Thanks for any assistance. (PS It is a bit urgent).
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 7 Sep 1999 16:00:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: integer mistery
Message-Id: <MPG.123f38e2c8b3c055989f23@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed. Followups cross-posted to
comp.lang.perl.misc, because I don't think there is a module for this.]
In article <7r4211$7n0$1@nnrp1.deja.com> on Tue, 07 Sep 1999 22:02:18
GMT, glaessel6281@my-deja.com <glaessel6281@my-deja.com> says...
> i encounterd a
> Integer Problem:
You also seem to have encountered a Newsreader Line-Break Problem. :-)
> I hava a Form to send the perl script a amount of
> Money (eg 18.10).
>
> what I did is to mult by 100 to get rid of the
> digits.
What you should do is treat money internally in units of cents
(integers), then divide by 100 for output.
> print "$p<BR>";
> $p=$p*100;
That converts the string '18.10' to the floating-point *approximation*
18.10
> print "$p<BR>";
That converts the floating-point approximaton back to a string. To see
what it really looks like, use "printf('%.20f', $p)" instead.
> $t=1810-$p;
That subtracts two numbers that are relatively close in magnitude. Kiss
precision goodbye.
> print "$t<BR>";
>
> if($p == int($p)){
> print "is eqaul<BR>";
> }else{
> print "not equal<BR>";
> }
> ------------------------
>
> 18.10
> 1810
> -2.27373675443232e-13
> is not equal
Don't use the internal conversion routines to convert '18.10' into a
floating-point number, which is only an approximation to the actual
value. Use integers for currency. ALWAYS!!!
$p =~ /(\d*)\.?(\d{0,2})/;
$cents = 100 * ($1 || 0) + ($2 || 0);
Now $cents is 1810 exactly. (It truncates rather than rounds if the
user inputs 18.109, for example; this can be fixed if significant.)
Note to experienced Perlers: The above conversion method isn't well
known or publicized, is it? Is this something for the FAQ? "How do I
convert decimal currency strings into cents?"
Note to Randal: No test for success is necessary for the above regex
before using $1 and $2. It always matches! :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 7 Sep 1999 16:10:02 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: integer mistery
Message-Id: <MPG.123f3b24e8475c96989f24@nntp.hpl.hp.com>
In article <7r4211$7n0$1@nnrp1.deja.com> on Tue, 07 Sep 1999 22:02:18
GMT, glaessel6281@my-deja.com <glaessel6281@my-deja.com> says...
...
For shame! You posted the same inquiry into two newsgroups without
cross-posting. Fortunately when I answered in the other newsgroup I
cross-posted here. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 8 Sep 1999 02:27:07 +0100
From: "Andrew Whitaker" <bigsleep@dircon.co.uk>
Subject: Re: large dataset problem
Message-Id: <37d5bb8a_1@newsread3.dircon.co.uk>
Makarand Kulkarni wrote in message <37D56983.98BDF059@cisco.com>...
>[ Benjamin Franz wrote:
>
>> You want to use a data structure like this:
>> $data->[$year]->[$month]->[$row]->[$column] = $value;
>
>Or else simple file indexing would work. After "freezing" the dataset
>file, write a script to create an index on the file with the following
>structure.
>
>year, month, row seekpos
>
>where seekpos where you would seek() to inside
>the file to position for (year, month, row)
I would definitely rule out importing the whole dataset into memory - far
too memory intensive.
Because you have a batch system where data is appended periodically to the
main data file, you might consider running a digest routine which reorders
the data by numerous ways i.e. the ways you need to access it.
Get Learning Perl from www.ora.com and look at seek,print,read etc as
Benjamin pointed out and digest your data into a reordered binary format
using probably pack( 'f' ) i.e. convert from Text to 4 bytes representing a
floating point number. This will then allow you to read all data for a point
on the globe in a single disk read, rather than hopping down the whole of
your 50Mb file. Another reason for the digest is to ensure odd anomalies in
source data formatting are coped with, in other words you are automatically
validating your new reading method, every digest time, against the full
dataset.
Private email me if you'd like me to give you a head start on a digest
routine and associated calls to extract data.
Andy Whitaker
Cimexmedia Ltd
------------------------------
Date: Wed, 8 Sep 1999 10:31:46 +1000
From: "Kim Saunders" <kims@emmerce.com.au>
Subject: modules in home dir (DynaLoader.pm)
Message-Id: <936750834.310424@draal.apex.net.au>
Hello all,
I'm having some probs with PerlMagick, the perl imagemagick interface
module. I don't have root on the machine I'm working one, but imagemagick
was successfully compiled in the home dir, with all libraries, etc, and the
imagemagick "convert" program works fine. Additionally, PerlMagick was
compiled and installed successfully.
The problem is this runtime error in the script with "use Image::Magick;":
Can't load '../i586-linux/auto/Image/Magick/Magick.so' for module
Image::Magick:
File not found at /usr/lib/perl5/i586-linux/5.004/DynaLoader.pm line 155.
So, what's that all about? ../i586-linux/auto/Image/Magick/Magick.so does
exist, it was put there by the perlmagick make install.
Pls, any help or suggestions are appreciated, so please help me out if you
can.
KimS
------------------------------
Date: Tue, 07 Sep 1999 18:14:32 -0700
From: Charlie Krauter <charlie@mother.com>
Subject: Re: Multithreaded client/server in Perl
Message-Id: <37D5B878.30729A59@mother.com>
Govind Shridhare wrote:
> Hi there
> I am using Linux 2.2 on a Pentium Machine.
> Can somebody send me Perl code for Multithreading client/server using
> Sockets?
> I couldn't find it anywhere in perl.com.
> The server they have is multithreaded. All it does is recognize the
> client's presence, send something to it but I don't know how to accept
> client input, process it and then send a reply back to client...The code
> appears below.
> Many thanks in advnace.
> Govind
>
> ##Server code
> #!/usr/bin/perl -Tw
> use strict;
> BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
> use Socket;
> use Carp;
> my $EOL = "\015\012";
>
> sub spawn; # forward declaration
> sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
>
> my $port = shift || 2345;
> my $proto = getprotobyname('tcp');
> $port = $1 if $port =~ /(\d+)/; # untaint port number
>
> socket(Server, PF_INET, SOCK_STREAM, $proto)|| die "socket: $!";
> setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
> pack("l", 1)) || die "setsockopt: $!";
> bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
> listen(Server,SOMAXCONN)|| die "listen: $!";
>
> logmsg "server started on port $port";
>
> my $waitedpid = 0;
> my ($paddr, $line);
>
> sub REAPER {
> $waitedpid = wait;
> $SIG{CHLD} = \&REAPER; # loathe sysV
> logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
> }
>
> $SIG{CHLD} = \&REAPER;
>
> for ( $waitedpid = 0;
> ($paddr = accept(Client,Server)) || $waitedpid;
> $waitedpid = 0, close Client)
> {
> next if $waitedpid and not $paddr;
> my($port,$iaddr) = sockaddr_in($paddr);
> my $name = gethostbyaddr($iaddr,AF_INET);
> logmsg "connection from $name [",
> inet_ntoa($iaddr), "]
> at port $port";
>
Here is where the spawn() subroutine gets called with a reference
to the code for whatever you want your server to do.
>
> spawn sub {
> print "Hello there, $name, it's now ", scalar localtime,
> $EOL;
> exec '/usr/games/fortune' # XXX: `wrong' line
> terminators
> or confess "can't exec fortune: $!";
> };;
>
> }
>
> sub spawn {
> my $coderef = shift;
>
> unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
> confess "usage: spawn CODEREF";
> }
> my $pid;
> if (!defined($pid = fork)) {
> logmsg "cannot fork: $!";
> return;
> } elsif ($pid) {
> logmsg "begat $pid";
> return; # I'm the parent
> }
> # else I'm the child -- go spawn
>
> open(STDIN, "<&Client") || die "can't dup client to stdin";
> open(STDOUT, ">&Client") || die "can't dup client to stdout";
> ## open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr";
> exit &$coderef();
> }
> -------------
> #Client code
> #!/usr/bin/perl -w
> use strict;
> use Socket;
> my ($remote,$port, $iaddr, $paddr, $proto, $line);
>
> $remote = shift || 'localhost';
> $port= shift || 2345; # random port
> if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
> die "No port" unless $port;
> $iaddr = inet_aton($remote) || die "no host: $remote";
> $paddr = sockaddr_in($port, $iaddr);
>
> $proto = getprotobyname('tcp');
> while (1)
> {
> socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
> connect(SOCK, $paddr)|| die "connect: $!";
> print SOCK "test";
>
> while (defined($line = <SOCK>)) {
> print $line;
> }
> close (SOCK)|| die "close: $!";
> }
>
> exit;
The idea behind the server code is that the subroutine reference passed to
spawn() executes when a client connects. All of that STDIN, STDOUT
redirection stuff inside of sub spawn is done so that your custom routine
can treat the client connection just like the console, so things like:
print "Hello client!\n";
and
while(<>) { ....
work just as you would expect.
I hope that helps.
-charlie
------------------------------
Date: Wed, 08 Sep 1999 00:49:25 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: mysql interview
Message-Id: <poiB3.305$S5.15616@ptah.visi.com>
Greg Bacon <gbacon@itsc.uah.edu> wrote:
: In article <eA%A3.376$96.26431@ptah.visi.com>,
: George Reese <borg@imaginary.com> writes:
: : Actually, no, it was not. It was a "for anything you might want to do
: : in perl, python works and it is easier to maintain". I do not think
: : perl sucks as such, even though I will say it out of hand. I simply
: : think perl serves no purpose any more.
: Are you going to justify any of this, or are you foaming at the mouth?
Somehow, I doubt anyone really wants a rehash of the thread from last
year. I think it is best to leave it at that being my feelings and
that a vast majority of this particular newsgroup believes otherwise.
--
George Reese (borg@imaginary.com)
http://www.imaginary.com/~borg
"The dead know only one thing: it's better to be alive"
-Joker in Full Metal Jacket
------------------------------
Date: Tue, 07 Sep 1999 17:53:44 +0000
From: Perfect Beat <prfctbt@cris.com>
Subject: opening files/secure server
Message-Id: <37D55127.AD63C6AC@cris.com>
I am having a problem opening files for writing from a secure server.
The process works fine while in non secure mode using relative paths. I
have tried to use absolute http and https paths but am not having any
luck. Does anyone have some insight?
Thanks!
Anthony
------------------------------
Date: Tue, 07 Sep 1999 23:27:10 GMT
From: Andy Molnar <anmolnar@videon.wave.ca>
Subject: Password Problem
Message-Id: <37D59F19.316207BE@videon.wave.ca>
I'm trying to run a script that registers a user with a user-defined
user name and a script-generated password consisting of eight random
alphanumeric characters (with lower-case letters). The script runs OK,
and tells the registrar what his/her password is, but that password
never works. I checked the .htaccess file, and the entry has been
added. It's as if the password was altered while getting encrypted.
Here's the code that creates and encrypts the password (I got the random
password generator from a library file in Extropia's "Database Manager",
and the rest from AHC CGI Factory's "Htpasswd Password Manager"):
srand(time|$$);
$random = "abcdefghijklmnopqrstuvwxyz1234567890";
$password = "";
for (1..8) {
$password .= substr($random,int(rand(36)),1);
}
$passcrypt = crypt($password, "YL");
open (wdata, ">>$passfile") or &error("Unable to write to the data
file");
if ($flock eq "y") {
flock wdata, 2;
}
print wdata "$form_data{'username'}:";
print wdata "$passcrypt\n";
close(wdata);
The code that shows the user the result is simply:
print qq~Your password is "$password"~;
Thankyou for any help you can provide.
Andy Molnar
------------------------------
Date: Wed, 08 Sep 1999 00:35:08 GMT
From: Andy Molnar <anmolnar@videon.wave.ca>
Subject: Re: Password Problem
Message-Id: <37D5AEF5.1F014D22@videon.wave.ca>
Nevermind, found the problem <stupid Stupid STUPID **WHACK**>
Andy
Andy Molnar wrote:
>
> I'm trying to run a script that registers a user with a user-defined
> user name and a script-generated password consisting of eight random
> alphanumeric characters (with lower-case letters). The script runs OK,
> and tells the registrar what his/her password is, but that password
> never works. I checked the .htaccess file, and the entry has been
> added. It's as if the password was altered while getting encrypted.
>
> Here's the code that creates and encrypts the password (I got the random
> password generator from a library file in Extropia's "Database Manager",
> and the rest from AHC CGI Factory's "Htpasswd Password Manager"):
>
> srand(time|$$);
> $random = "abcdefghijklmnopqrstuvwxyz1234567890";
>
> $password = "";
> for (1..8) {
> $password .= substr($random,int(rand(36)),1);
> }
>
> $passcrypt = crypt($password, "YL");
>
> open (wdata, ">>$passfile") or &error("Unable to write to the data
> file");
>
> if ($flock eq "y") {
>
> flock wdata, 2;
>
> }
> print wdata "$form_data{'username'}:";
> print wdata "$passcrypt\n";
>
> close(wdata);
>
> The code that shows the user the result is simply:
>
> print qq~Your password is "$password"~;
>
> Thankyou for any help you can provide.
>
> Andy Molnar
------------------------------
Date: Wed, 8 Sep 1999 10:24:57 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Pattern Matching Question
Message-Id: <MPG.124057e2b65cea93989cb5@news-server>
stuart.mcintosh@db.com writes ..
>I'm trying to come up with something that will match all of the
>following when they come up in the middle of a line of text (I use 'POS'
>to set the search start position to the correct starting place first)
>
>123.45678 P
> 3.4567890P
> 23.456789
>
>I tried m/\S+\s*\S/g - according to the "programming perl" book the \s*
>should match zero or more occurances of a whitespace character but I
>found it was failing on the second example above...
it fails because on the second one the first \S+ matches everything ..
then the \s* successfully matches a zero length string .. but then the
regex wants a second \S .. but it can't find it because the whole string
was matched by the \S+
given the specs that you've provided the following will work
/\d+\.\d+\s*P?/;
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: 07 Sep 1999 16:50:58 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Programmer's Editor
Message-Id: <m1zoyyxov1.fsf@halfdome.holdit.com>
>>>>> "Jussi" == Jussi Jumppanen <jussij@zeusedit.com> writes:
Jussi> 2) Comes with pre-configured syntax highlighting for:
Jussi> C/C++, Java, Perl, HTML, Python, Pascal
I bet ya it's easy to confuse it with Perl code.
Does it get both of these right:
time /3 ;#/; print "hello";
sin /3 ;#/; print "goodbye";
As in, does it highlight the "print" in print "hello" as a comment,
and the "print" in print "goodbye" as a keyword and string?
OK, then does it get this one right:
sub barney ();
sub fred ($);
barney /3 ;#/; print "hello";
fred /3 ;#/; print "goodbye";
Ditto on the print mapping.
And if so on that, does it get this right:
use Flintstones::Fred_n_Barney qw(fred barney); # remember to write this
barney /3 ;#/; print "hello";
fred /3 ;#/; print "goodbye";
Syntax highlighting for Perl. I'll believe it when I see it.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 8 Sep 1999 10:39:07 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Programmer's Editor
Message-Id: <MPG.12405b3989eaf327989cb6@news-server>
Randal L. Schwartz writes ..
>Syntax highlighting for Perl. I'll believe it when I see it.
thing is that with syntax highlighting (as with a lot of things)
"useful" is a subset of "complete"
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Tue, 07 Sep 1999 23:11:49 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Question about a hash
Message-Id: <rtb6tloi8os58@corp.supernews.com>
I need an array to look like this:
@data = ( [@new_array_time],
[@{$input_params{'cpu_usr'}}],
[@{$input_params{'cpu_sys'}}],
[@{$input_params{'cpu_wio'}}],
[@{$input_params{'cpu_idle'}}]
);
The hash is %input_params. I am trying to build the above like this and fails
to built it exactly the way it is above. I think it is missing the square
brackets. Any thoughts on how to put them there?
foreach $key (sort keys %input_params)
{
if ($key ne 0)
{
push (@data, @{$input_params{$key}});
}
}
===========================================================================
www.e-gold.com
E-gold: Unlike unredeemable Federal Reserve Tokens, e-gold is money that is
100% backed by a metal of your choice: gold, silver, platinum or palladium.
===========================================================================
------------------------------
Date: Wed, 08 Sep 1999 01:46:57 GMT
From: mingtian@hanmail.net (Gilly)
Subject: Re: reading special character(? EOF or NULL?) from Socket handle?
Message-Id: <37d5bfdf.84957313@news.nuri.net>
:did you try
:
: binmode(S);
:
:before the read?
yes but it still reads only few chars..
@}`,--- ¢¾£Æ¨Û¥Ôg¥å©à £íe ¥Í¥ï¨à
ICQ: 15668514
------------------------------
Date: Tue, 07 Sep 1999 18:12:49 +1700
From: ScrO <zomzomNOkmSPAM@hotmail.com>
Subject: Referencing another server?
Message-Id: <1415c574.918e2620@usw-ex0102-015.remarq.com>
Can antone tell me how to reference another server from
within a perl script?
ie:
$mailprog = '/usr/sbin/smail';
but I want to reference a seperate internal server (named
"rocky" for example).. any ideas?
E-mail me at alyon@vitria.com if you can figure it out.
Thanks,
Adam
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 07 Sep 1999 20:18:59 -0400
From: "Z. Huang" <zhuang@ic.sunysb.edu>
Subject: very simple question.
Message-Id: <37D5AB72.8FEFB7BF@ic.sunysb.edu>
Can anyone tell me how to continue in a new line? suppose I want to
print as follows
print "this is the first line\n"
."this is the second line\n"
It doesn't go through. I guess something is missing at the end of the
first line. Any hint is appreciated.
------------------------------
Date: Wed, 08 Sep 1999 00:53:23 GMT
From: Andy Molnar <anmolnar@videon.wave.ca>
Subject: Re: very simple question.
Message-Id: <37D5B342.403AA27C@videon.wave.ca>
Try this:
print <<EOF;
this is the first line
this is the second line
EOF
Everthing between the EOF's is printed to the html file the way you see
it above. Any character normally used in a regular expression will be
printed literally on the html page with the exception of the scalar ($),
so you can still put variables inside as you would with quotes.
I've also seen this:
print qq~this is the first line
this is the second line
~;
Does the same as EOF above. You can use any character instead of the
tilde, but since the tilde is hardly used in html, it's ideal.
"Z. Huang" wrote:
>
> Can anyone tell me how to continue in a new line? suppose I want to
> print as follows
> print "this is the first line\n"
> ."this is the second line\n"
> It doesn't go through. I guess something is missing at the end of the
> first line. Any hint is appreciated.
------------------------------
Date: Tue, 7 Sep 1999 17:54:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: very simple question.
Message-Id: <MPG.123f5395edaeb4c6989f26@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <37D5AB72.8FEFB7BF@ic.sunysb.edu> on Tue, 07 Sep 1999
20:18:59 -0400, Z. Huang <zhuang@ic.sunysb.edu> says...
>
> Can anyone tell me how to continue in a new line? suppose I want to
> print as follows
> print "this is the first line\n"
> ."this is the second line\n"
> It doesn't go through. I guess something is missing at the end of the
> first line. Any hint is appreciated.
Maybe a semicolon is missing at the end of the second line.
In addition to your code (with a semicolon), any of the following should
work:
print "this is the first line\nthis is the second line\n";
print "this is the first line
this is the second line
";
print <<END;
this is the first line
this is the second line
END
I suspect you are trying to print HTML to a browser, in which case you
need '<BR>' for the browser, as well as "\n" for anyone who reads the
HTML source.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 7 Sep 1999 16:04:36 -0700
From: moseley@best.com (Bill Moseley)
Subject: What the flock?!?
Message-Id: <MPG.123f39da7c9c2c16989715@nntp1.ba.best.com>
What's so 'bad' about $fh?
I noticed I wasn't checking the return value from flock. So I added a
die(), as shown below. Here's there error that's placed in my log file.
30) ~/public_html/lii/indexer %tail error.log
Lock mode = 1
hello
Failed to secure lock: Eval returned:'failed to set lock 'Bad file
number' at LII.pm line 1550'.
' (Bad file number) at LII.pm line 1565.
flock() is at line 1550 in my source file.
I'm opening STDERR to a file and then caling lock_file()
if (open( STDERR, ">>$path" ) ) {
lock_file( *STDERR ); # lock with a shared lock
} else {
print why
}
use Fcntl ':flock';
sub lock_file {
my $fh = shift;
my $lock_mode = shift(@_) ? LOCK_EX : LOCK_SH;
print STDERR "Lock mode = $lock_mode\n";
print $fh "hello\n";
eval {
# Set timeout
local $SIG{ALRM} = CORE::sub { die "Timed out Waiting for File
Lock\n" };
alarm ($params{wait_time} || 10 );
flock( $fh, $lock_mode ) or die "failed to set lock '$!'";
alarm 0;
};
if ($@) {
die("Failed to secure lock: Eval returned:'$@' ($!)");
}
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 735
*************************************