[7097] in Perl-Users-Digest
Perl-Users Digest, Issue: 722 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 11 18:17:44 1997
Date: Fri, 11 Jul 97 15:00:42 -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 Fri, 11 Jul 1997 Volume: 8 Number: 722
Today's topics:
'' and "" + a question to the C Wizards <ymc@umich.edu>
Re: 'use strict' with CGI.pm <rootbeer@teleport.com>
Re: 'use strict' with CGI.pm (Jay Flaherty)
Re: [Q] Perl-5.004, localtime & timelocal (M.J.T. Guy)
Re: Dear Spammer! We are NOT happy with you. <ddirecto@sungardams.com>
Re: Dear Spammer! We are NOT happy with you. (Trey Valenta)
Re: Deleting all spaces at the beginning of a line. (Tung-chiang Yang)
Directory Polling <bat@unifi.com>
Re: empty package "DBI" <rootbeer@teleport.com>
eof() && sockets? <christopher_mason@sterling.com>
Re: foreach array indices <rootbeer@teleport.com>
Re: Help! what is a ")) string"??? <rootbeer@teleport.com>
Re: HELP: Activeware's-->Sarathy's Perl: OLE doesn't wo (Gurusamy Sarathy)
HELP: sockets <th3i+@andrew.cmu.edu>
Re: How to save in File ??? <brandon@physics.utexas.edu>
Re: How to substract a uniq integer from a ASCI string (Sandy Harris)
Re: How to substract a uniq integer from a ASCI string (Patrick Juola)
Re: Need the straight poop on setuid perl <rootbeer@teleport.com>
Re: Newbie needs help with searching an array <ajohnson@gpu.srv.ualberta.ca>
Re: Newbie needs help with searching an array (Andrew M. Langmead)
Perl and DBD-Orable <poon@samart.co.th>
perl script inside perl script datta@hcla.com
Re: set userid of perl script <rootbeer@teleport.com>
Setting TARGET variable from Perl Script <solutions@ix.gen.com>
Re: shift on an empty array returns ( undef ) in a list <rootbeer@teleport.com>
Re: Sorting (Walter Tice USG)
Re: Tracking running time?? <sveerara@cisco.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 Jul 1997 15:19:55 -0400
From: "Yee Man, Chan" <ymc@umich.edu>
Subject: '' and "" + a question to the C Wizards
Message-Id: <33C6875A.C66D8DB6@umich.edu>
$a = "a";
$temp1 = '${a}bc\n';
$temp2 = "${a}bc\n";
It is evident that if we print $temp1 and $temp2, they will give
different results. But, how can I transform $temp1 to $temp2 without
doing an explicit assignment? Is there any built-in functions or handy
ways in Perl allow us to do that?
Here is a mysterious little C program which I obtained from the web. It
is said to be able to compute pi. It really works and prints 3.156. Can
any C Wizards out there can help me to understand it?
#define _ F-->00 || F-OO--;
long F=00,OO=00;
main(){F_OO();printf("%1.3f\n", 4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_
}
------------------------------
Date: Fri, 11 Jul 1997 08:19:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bernard Cosell <bernie@rev.net>
Subject: Re: 'use strict' with CGI.pm
Message-Id: <Pine.GSO.3.96.970711081742.10200J-100000@kelly.teleport.com>
On Thu, 10 Jul 1997, Bernard Cosell wrote:
> I'm fond of using 'use strict', but I run into trouble when I try to
> use various modules. The problem de jour is with CGI.pm. First sign
> of trouble is when I went to do:
> use CGI shortcuts;
> and got a 'bareword' error.
That's not CGI.pm's fault; Perl is seeing the bareword 'shortcuts' and
complaining about it before CGI.pm gets a look at it. What you want is to
quote it somehow. The most-common way is to use qw, which is documented in
perlop.
use CGI qw(shortcuts);
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 11 Jul 1997 14:21:10 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: 'use strict' with CGI.pm
Message-Id: <5q5fgm$j5o$1@gaia.ns.utk.edu>
Honza Pazdziora (adelton@fi.muni.cz) wrote:
: bernie@rev.net (Bernard Cosell) writes:
:
: > Hi--
: >
: > I'm fond of using 'use strict', but I run into trouble when I try to
: > use various modules. The problem de jour is with CGI.pm. First sign
: > of trouble is when I went to do:
: > use CGI shortcuts;
: > and got a 'bareword' error. And throughout I get errors like:
: >
: > Unquoted string "startform" may clash with future reserved word at
: > checkhours.pl line 43.
: >
: > Is there some general way to arrange 'tidy' access to CGI.pm so that
: > use strict; will be happy? Thanks!
:
: I think it's not problem with CGI.pm. Try
:
: use CGI 'shortcuts';
:
: The error is reported before the use CGI is even called.
:
This will get rid of the first error message but not the "unquoted string"
error messages (and others). You need to fully qualify those constructs. I
find it easier to avoid the CGI.pm 'shortcuts' and ':standard' qulaifiers
when using 'strict'. ie:
#!/usr/local/bin/perl -Tw
use strict;
use vars qw($CASED $BKGRND1 $FOOTER);
use CGI;
use lib "/usr/local/apache/lib/access.pl";
###########################################################
# Begin Main Program
my $query = new CGI;
my $case = $query->param('case');
my $image = $query->param('image');
my $text = $query->param('text');
my $path = &casepath($case);
my $textfile = "$CASED/$path/$case/images/$text";
etc...
Jay
--
**********************************************
Jay Flaherty fty@utk.edu
If software was free, who would pay "THE BILL"
**********************************************
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBM2jQn1OdOzizdT/5AQHaWwP/bECLFr26GWHmszDuKUXCABW9cBuhqD9z
+JrJY+jRxF8yiV8ofkbma2vXi833RFDOz4vWZRetmjSV46MiDv5xzUatjyJnr57m
DadIYs9h0geGS6WOhJyy9dRI+YqQreQRa0QUW6NhYjdJJSrN/naYhPOfgS1mGhHX
P0RIJXP5JKI=
=edAe
-----END PGP SIGNATURE-----
------------------------------
Date: 11 Jul 1997 09:01:50 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: [Q] Perl-5.004, localtime & timelocal
Message-Id: <5q4spu$cmh@lyra.csx.cam.ac.uk>
Keywords: Perl-5.004, localtime, timelocal
Wong Tsang Han <tsanghan@pacific.net.sg> wrote:
>I wonder if anyone have come accross a failed timelocal test.
Yes. Several of your compatriots have. It's a problem which only seems
to affect people in Singapore.
There is a bug in Time::Local which causes it to give wrong answers if
the timezone offset has changed since Jan 1st 1970. This has happened
in Singapore but AFAIK not anywhere else.
As far as the Perl installation is concerned, you can ignore the errors.
But if you try to use the local options of Time::Local, you'll get
wrong answers.
Mike Guy
------------------------------
Date: Fri, 11 Jul 1997 12:07:39 -0500
From: David Director <ddirecto@sungardams.com>
Subject: Re: Dear Spammer! We are NOT happy with you.
Message-Id: <33C6685B.3338@sungardams.com>
Richard Greene wrote:
>
> There is a WEB site run by the E-MAIL Marketing Council. They "claim" that if
> you register with them to have your name removed from mailings by their
> "spammer" members they will pass it to them. Their main interest is to stop
> pending congressional legislation which could potentially put them out of
> business. Their address is
> http://www.jemmc.org
I just tried to get to that web site and got a 404 message, "hostname
unknown".
-- David
------------------------------
Date: 11 Jul 1997 16:57:31 GMT
From: trey@zipcon.net (Trey Valenta)
Subject: Re: Dear Spammer! We are NOT happy with you.
Message-Id: <868640279.769730@ran.zipcon.net>
In <33C6685B.3338@sungardams.com> David Director <ddirecto@sungardams.com> writes:
>> you register with them to have your name removed from mailings by their
>> "spammer" members they will pass it to them. Their main interest is to stop
>> pending congressional legislation which could potentially put them out of
>> business. Their address is
>> http://www.jemmc.org
>I just tried to get to that web site and got a 404 message, "hostname
>unknown".
It's www.iemmc.org. It's run by essentially AGIS, cyberpromo, et al.
Lot's of mention on news.admin.net-abuse.email and such regarding
whether it works. I admit i haven't seen any mail from cyberpromo in a
bit, but I get tons from elsewhere. And given AGIS' ability to run their
networks based on past performance, anything is posible.
--
Trey Valenta trey@zipcon.net Seattle, WA
------------------------------
Date: Fri, 11 Jul 1997 21:31:22 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Deleting all spaces at the beginning of a line.
Message-Id: <tcyangED6BsB.3I4@netcom.com>
If $a contains the line read from the file you are interested, use
$a =~ s/^\s+//;
I don't think 'chomp' works on the leading white spaces.
===========================================
Dana W. Edwards wrote after zapping the scum of the universe:
: Hello!
: I am having trouble deleting all the white space at the beginning of a
: line of text. How would I do this without chomping the rest of line?
--
====== Try the low-crossposting robomoderated 'alt.culture.taiwan' ======
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Fri, 11 Jul 1997 16:42:34 -0400
From: Boris Tabenkin <bat@unifi.com>
Subject: Directory Polling
Message-Id: <33C69AB9.EF3D27A6@unifi.com>
This is a multi-part message in MIME format.
--------------BAB94F5F41B764182E1AAF16
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit
I am interested in writing a program which need to scan directories for
new files. I know that under WIN32 there is a way of setting up a system
event which will notify a waiting thread (via WaitForSingleEvent for
example) that a new file has just been written to a directory. I have 2
question 1) can this functionality be somehow exploited under PERL in
the WIN32 environment, without having to write a OLE control of some
sort 2) how can I do the same under UNIX. Can select(2) be used?
Also, is anyone aware of any way of implementing threads in PERL under
Linux an/or Win32.
Any advise is always appreciated!
Boris Tabenkin
--------------BAB94F5F41B764182E1AAF16
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Boris Tabenkin
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Boris Tabenkin
n: ;Boris Tabenkin
email;internet: bat@unifi.com
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
end: vcard
--------------BAB94F5F41B764182E1AAF16--
------------------------------
Date: Fri, 11 Jul 1997 08:01:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Uma Shanker <uma@heidelbg.ibm.com>
Subject: Re: empty package "DBI"
Message-Id: <Pine.GSO.3.96.970711075703.10200H-100000@kelly.teleport.com>
On Tue, 8 Jul 1997, Uma Shanker wrote:
> what it means
>
> Can't call method "install_driver" in empty package "DBI" at ./erste.pl
> line 9.
It means that Perl hasn't seen a definition for anything in the DBI
package, at the time that you start to use it.
> #use DBI;
>
> $drh = DBI->install_driver('DB2');
Did you mean to comment out the "use" statement? That looks like the
problem. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 11 Jul 1997 14:29:39 -0500
From: Chris Mason <christopher_mason@sterling.com>
Subject: eof() && sockets?
Message-Id: <33C689A3.149F@sterling.com>
All-
Having some problems with eof() and nonblocking sockets. For example
(I'm abrieviating code that I know works):
socket(Incoming,...) || die(...);
bind(Incoming,...) || die (...);
listen(Incoming,...) || die(...);
fcntl(Incoming, F_SETFL, O_NONBLOCK) || die (...);
$tempsocket = new FileHandle;
while (...) {
$paddr = accept($tempsocket, Incoming);
if ($paddr) { #we've got a new connection
fcntl($tempsocket, F_SETFL, O_NONBLOCK) || die();
$storesocket = $tempsocket;
$tempsocket = new FileHandle;
eof ($storesocket) && die("oh dear.\n");
# always "oh dear."
}
select(), etc...
}
This is contrived, but the only way I can think to tell if the socket
has closed on me, is to use eof(), and it always returns true.
TIA.
-c
--
Chris Mason <christopher_mason@sterling.com> -- Sterling Software
"...the monstrous thing is not that men have created roses out of
this dung heap, but that...they should _want_ roses." -H. Miller
------------------------------
Date: Fri, 11 Jul 1997 09:32:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eric Kissinger <erick@servtech.com>
Subject: Re: foreach array indices
Message-Id: <Pine.GSO.3.96.970711092428.10200V-100000@kelly.teleport.com>
On Fri, 11 Jul 1997, Eric Kissinger wrote about his earlier question about
getting the index of the iterator during a foreach loop:
> So I guess the answer to my question is no?
That's correct; if we had a way to find out where the iterator is in this
loop...
foreach (@foo) { ... }
...what would this have to do? :-)
foreach (1, 2, @foo, @bar, 5..$x) { ... }
(And how could you handle nested loops which both iterate over @foo? There
are ways, I suppose, but it gets more and more overblown.)
> The for loop method is obvious, it would seem that perl would have some
> shortcut as usual for the foreach loop method
You can use this to iterate through a small array if you don't want to
write the three-part for loop:
foreach (0..$#foo) { ... $foo[$_] ... }
Of course, you refer to the index as $_ and the element as $foo[$_] inside
the loop, when you use this method. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 11 Jul 1997 09:04:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bernard Cosell <bernie@rev.net>
Subject: Re: Help! what is a ")) string"???
Message-Id: <Pine.GSO.3.96.970711085709.10200Q-100000@kelly.teleport.com>
On Fri, 11 Jul 1997, Bernard Cosell wrote:
> syntax error at checkhours.pl line 58, near ");"
> (Might be a runaway multi-line )) string starting on line 57)
>
> What is a "multi-line )) string"??
Perl thinks that you might have a multiple-line string that didn't have a
proper closing paren. (Although it's not obvious where the "))" came from
in that message.)
> the code in that vicinity looks like:
> [ .... ]
> tr(td({-align => "center"},
> input {-type => "submit", -value => "Submit"} ))
> )
> );
Chances are quite good that either your quotes or parens don't quite match
up, and what looks like code to you and me looks like a quoted string to
Perl. These problems can be hard to track down, but usually the problem is
somewhere in the previous five or six lines. So, I'd take a look at lines
50 to 60, and you'll probably spot the problem. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 11 Jul 1997 05:43:43 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: HELP: Activeware's-->Sarathy's Perl: OLE doesn't work anymore.
Message-Id: <5q4h6f$bnf@srvr1.engin.umich.edu>
[ mailed (despite the nospam rudeness) and posted ]
In article <33c461d8.13914097@news1.radix.net>,
<read.below.for.address> wrote:
>On Thu, 10 Jul 1997 04:03:08 GMT, nospam@is.good.spam.com wrote:
>>In the new constructor of \perl\lib\site\win32\ole.pm, CreateObject
>>fails everytime: (I verified this with print statements.)
There's an oversight in OLE.xs that affects builds with the Borland
compiler. People who built it with the VC++ compiler shouldn't see
it. The fix is in the next binary release (coming in a few
days).
- Sarathy.
gsar@umich.edu
----------------------------8<----------------------------
--- /temp/t180t0.tmp Fri Jul 11 01:36:08 1997
+++ OLE.xs Fri Jul 11 01:31:10 1997
@@ -752,7 +752,12 @@
}
BOOL APIENTRY
-DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpvReserved)
+#ifdef __BORLANDC__
+DllEntryPoint
+#else
+DllMain
+#endif
+(HANDLE hModule, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
------------------------------
Date: Fri, 11 Jul 1997 12:59:26 -0400
From: Timothy A Howe <th3i+@andrew.cmu.edu>
Subject: HELP: sockets
Message-Id: <4nlaNiC00Xe7059Ek0@andrew.cmu.edu>
I have been having a problem regarding a socket program
I have written that is going to be a piece of a tape backup
system. Essentially it consists of a server (the machine to
be backed up) and a client (machine with tape drive). The server
sits and waits until it is connected to by the client, they exchange
some nominal info (hello world), and then start to dump info.
I am using gtar with compression (though I have also experimented
with non-gnu tar, gtar w/o compression, and several arbitrary other
commands with the same results. The problem is this: at the end of
the transfer, the server crashes with the message:
Unable to create sub named "" at socket_test_server.pl line 49
(note that the line number is subject to change randomly)
Everything copies correctly and I am able to retrieve the record
off of the tape. I have determined that it is definately related
to something about the socket itself as this works if you make the
client a file instead of a socket.
I have consulted all of the man pages I could find, the o'reilly
Perl book (2nd ed.), the solaris sysadmin book, the red book, and
the phone book (just for consistancy). I am running this on two
machines running Solaris 2.5.1 though I have also tested it on Linux
and HP/UX with the same problems.
Any help would be much appriciated and at this point I will even
accecpt random guesses.
the code is as follows (server then client)
(note: this is not pretty code, I am new at perl, I write like a c programmer)
require 5.002;
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;
$port = 2536; #randomly choosen port (5^2 6^2)
$proto = getprotobyname('tcp'); #use tcp protocall
socket(Server, PF_INET, SOCK_STREAM, $proto) or die "died on socket $!";
#get socket, bind socket etc.
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1))
or die "setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) or die "bind: $!";
listen(Server,SOMAXCONN) or die "listen: $!";
$SIG{CHLD} = \&REAPER;
$paddr = accept(Client,Server); #accecpt connection from socket and
assign to new port
($port,$iaddr) = sockaddr_in($paddr); #assign values for newly
connected machine
$name = gethostbyaddr($iaddr,AF_INET);
sysread(Client, $incoming, 200); #read from network (to
be used in the future as a test)
print "\nMessage from $name : ".$incoming."\n" ;
$len_test = length $incoming;
syswrite(Client, $incoming ,$len_test); #return message to Client
open(Tar, "/usr/contributed/bin/gtar -czf - test |"); #open command
line tar as a pipe
$length = 512;
#while loop reads into a buffer ($in_buffey) from tar in 512 byte blocks.
#it then writes to the socket in 512 byte blocks.
while($length = sysread(Tar, $in_buffey, 512) || die "Dead at WHILE" ) {
#if ($length < 512) {
# $temp_buffey = " ";
# $temp_addon = " "; #this code is useless
because tar
# for ($x = $length-1 ; $x <= 512 ; $x++){ #automatically returns
512 byte blocks
# $temp_buffey = $temp_buffey.$temp_addon;
# } #I used this for
testing other commands
# $in_buffey = $in_buffey.$temp_buffey; #(other than tar)
# $length = length $in_buffey;
# print "looped\n";
#}
#print "not yet to syswrite, buffer length: $length\n"; #debugging code
syswrite(Client, $in_buffey, $length); #write to socket
#print "made it past syswrite, buffer length: $length\n";
}
print $length;
^^^^^^^^^^^^^^^^^^^^^^^^
End of server code
-------------------------
Begin Client code
vvvvvvvvvvvvvvvvvvvvvvvvv
#!/usr/bin/perl -w
require 5.002;
use Socket;
print "Enter server name: "; #get name of server and use it
$server = <stdin>;
chop $server;
$remote = shift || $server;
$port = shift || 2536; # random port
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') } #get
port, name, protocall, etc.
die "No port" unless $port;
$iaddr = inet_aton($remote) or die "no host: $remote";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!"; #open socket
connect(SOCK, $paddr) or die "connect: $!";
#connect to server
$test = "\nHello World!";
$len_test = length $test;
syswrite(SOCK, $test ,$len_test); #write to socket
sysread(SOCK, $test, 20); #read response
print $test."\n" ; #print response
open (Dd, "| dd ibs=512 obs=512 of=/dev/rmt/0 conv=sync"); #open pipe
into the dd command to write to tape
while ($length = sysread(SOCK, $out_buffey, 512)){ #read from socket in
512b blocks
syswrite(Dd, $out_buffey, 512); #write to tape
}
close (SOCK) or die "close: $!";
exit;
------------------------------
Date: Fri, 11 Jul 1997 09:49:01 -0500
From: "Brandon W. Metcalf" <brandon@physics.utexas.edu>
To: Martin Neubauer <MFNeubauer@ThePentagon.com>
Subject: Re: How to save in File ???
Message-Id: <33C647DD.41C6@physics.utexas.edu>
Martin Neubauer wrote:
>
> Hello,
>
> I'm a newcomer in perl Programming ...
> can you tell me how i can change the following Perl Programm to print
> the output, and save it to harddisk.
> Each form should appendet to a file ...
open FILE, ">>$filename";
print FILE "Whatever you want to print";
close FILE;
FILE is the file handle name which can be anything you like.
--
Brandon Metcalf
UNIX Systems Administrator
Department of Physics - UT Austin
brandon@physics.utexas.edu
------------------------------
Date: Fri, 11 Jul 1997 15:22:44 GMT
From: sandy@storm.ca (Sandy Harris)
Subject: Re: How to substract a uniq integer from a ASCI string
Message-Id: <5q5j3p$d1d$1@news2.storm.ca>
toutatis@remove.this.toutatis.net (Toutatis) wrote:
:Could anybody advise me on how to create from a given string
:an integer that somehow is (quite) unique for that character string?
:
Grab a stong hash function out of one of the crypto libraries listed
in the sci.crypt FAQ.
:I came up with the following solution myself in perl:
:
:foreach(unpack('C*',$string)){
: $code += $_;
:}
:
:It simply returns the sum of all ASCI values.
:
:but this way, toutatis results in the same code as titatous. I need
:something less easy to "crack" than this.
Using C, since I don't speak Perl, one possibility is:
#define Csize 7 // number of bits used in character set
#define Usize 32 // bits in unsigned int
// maximum you can left-shift a character by without losing bits
#define MAX_SHIFT (Usize-Csize-1)
#define ARBITRARY 0x987654ab
unsigned hash( char *p)
{
int shift, value ;
for( shift = 0, value = ARBITRARY ; *p ; p++, shift++ ) {
if( shift > MAX_SHIFT) shift = 0 ;
value += *p << shift ;
}
return value ;
}
Still very far from ideal, but better than just adding them.
------------------------------
Date: 11 Jul 1997 08:43:03 GMT
From: patrick@gryphon.psych.ox.ac.uk (Patrick Juola)
Subject: Re: How to substract a uniq integer from a ASCI string
Message-Id: <5q4rmn$dtb@news.ox.ac.uk>
In article <toutatis-ya023180001007972039030001@news.euro.net> toutatis@remove.this.toutatis.net (Toutatis) writes:
>Hi,
>
>Could anybody advise me on how to create from a given string
>an integer that somehow is (quite) unique for that character string?
>
>I came up with the following solution myself in perl:
>
>foreach(unpack('C*',$string)){
> $code += $_;
>}
>
>It simply returns the sum of all ASCI values.
>
>but this way, toutatis results in the same code as titatous. I need
>something less easy to "crack" than this.
>And my returned codes vary from string-length * 97 to string-length * 122,
>where I prefer to use the *complete* integer "spectrum" to represent this
>string.
>Although I prefer the returned code to be an integer, a fixed width string of
>say 6 characters would be fine too.
>
>Anybody any clues on this?
There are actually two questions buried here. One is the string-uniqueness
problem, that of preventing collisions from appearing by accident. The
other is the security problem, that of preventing collisions by
design.
If you need security, then get yourself a good one-way hash function
out of the literature; someone has already posted SHA.
If all you need is protection from accidental collisions, the easiest
thing to do would be to add some sort of base-coding. You could do
pretty well with something as simple as
foreach(unpack('C*',$string)){
$code = (2*$code) + $_;
}
------------------------------
Date: Fri, 11 Jul 1997 08:41:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Schoenfeld <chris@ixlabs.com>
Subject: Re: Need the straight poop on setuid perl
Message-Id: <Pine.GSO.3.96.970711083824.10200O-100000@kelly.teleport.com>
On Fri, 11 Jul 1997, Chris Schoenfeld wrote:
> If you are on Solaris:
>
> What happens when you run a setuid perl script which points to the
> 'perl' (not sperl) executable? Does it run sperl anyway? What if sperl
> has been removed?
Unless I'm mistaken, Solaris doesn't have (or need) a suid executable.
Setuid scripts are (AFAIK) secure there.
> What is taintperl and tperl? When/how are they invoked?
They were used in version 4 of perl, but they're not needed any more.
> What about on Linux, where the kernel ignores setuid bits on scripts?
If you want setuid scripts on Linux, you just compile that feature into
Perl. The perl binary calls the setuid one when needed, so you ignore it
forever after.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 11 Jul 1997 16:24:15 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Newbie needs help with searching an array
Message-Id: <33C6A47F.74728B8E@gpu.srv.ualberta.ca>
Peter wrote:
!
! I'm having trouble getting the following to work anf would
! appreciate any help that anyone could give.
!
! I basically have two arrays of user names and want to know
! if the users listed in the source array exist in the
! destination array. What am I doing wrong?
!
! ************* Begin Code:
! @sourceUsers = ("me", "him", "her", "it");
! @destUsers = ("her", "it");
!
! foreach $userName (@sourceUsers) {
! if (@destUsers =~ /$userName/) {
! print "$userName already exists in dest\n";
! } else {
! print "$userName does not exist in dest\n";
! }
! }
! ************* End Code:
when you use @destUsers=~/$userName/
the scalar value of @destUsers is used...which isn't what you
want. Either put the array into quotes to stringify it
"@destUsers"=~/$userName/
or use hashes instead and use the exists() function to check
if a key in one hash exists in the other.
regards
andrew
------------------------------
Date: Fri, 11 Jul 1997 21:35:15 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Newbie needs help with searching an array
Message-Id: <ED6Byr.85I@world.std.com>
Peter <petergi@synopsys.com> writes:
>I basically have two arrays of user names and want to know if the users
>listed in the source array exist in the destination array.
>@sourceUsers = ("me", "him", "her", "it");
>@destUsers = ("her", "it");
Well, the closest thing to the way you were doing it would be:
for $sourceuser (@sourceUsers) {
my $founduser;
for $destuser (@destUsers) {
if( $sourceuser eq $destuser) {
$founduser = $destuser;
break;
}
}
if($founduser) {
print "$founduser already exists in dest\n";
}
else {
print "$founduser does not exist in dest\n";
}
}
Notice that we need to iterate around @destUsers. The match anchor
operator takes a scalar on the left hand side and either a match or
substitute operator on the right.
You could interpolate @destUsers into a double quoted string
"@destUsers" =~ /$userName/;
but you run into problems that a match that contains a space can match
two consecutive elements in the array. (Not a problem in this case,
but if you used this technique, you might want to comment that
limitation for maintenance. Also, you are depending that no element in
@sourceUsers contain any regular expression metacharacters.)
Ok, so I've answered the question "what is wrong with this code." I'd
be doing you a disservice, though, if I didn't answer the question you
didn't ask, "what is the most efficient way of find the elements
common between two lists." The answer is in the FAQ, <URL:http:
//www.perl.org/CPAN/doc/manual/html/pod/perlfaq4/
How_do_I_compute_the_diference_.html>
--
Andrew Langmead
------------------------------
Date: Thu, 10 Jul 1997 21:13:28 -0600
From: Poon Rojanasoonthon <poon@samart.co.th>
Subject: Perl and DBD-Orable
Message-Id: <868586385.27533@dejanews.com>
Hi all,
I have some problem with running perl with Oracle using DBI and DBD.
Everytime the server was connected, the server always fork 1 process. And
Oracle is 28M, sometimes it fork over 10 processes...Someone have any idea
?
-poon
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 11 Jul 1997 15:13:00 -0600
From: datta@hcla.com
To: datta@hcla.com
Subject: perl script inside perl script
Message-Id: <868651107.10086@dejanews.com>
How to call a perl script inside a perl script?
Datta.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 11 Jul 1997 08:32:26 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Juriaan Kellermann <j.kellermann@pukka.com>
Subject: Re: set userid of perl script
Message-Id: <Pine.GSO.3.96.970711083054.10200M-100000@kelly.teleport.com>
On Thu, 10 Jul 1997, Juriaan Kellermann wrote:
Newsgroups: comp.lang.perl
If your news administrator still carries comp.lang.perl, please encourage
him or her to check out the frequent posting about bogus newsgroup names
in news.announce.newgroups. You'll be doing yourself and many others a
favor to use comp.lang.perl.misc (and other valid Perl newsgroups)
instead.
news:news.announce.newgroups
> Does anyone know if it's possible to run a Perl script as if it were a
> specific user?
Yes; you can make it setuid, if that's supported by your system, or if
that feature was compiled into Perl on your site. Be sure to read
perlsec(1). Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 09 Jul 1997 14:00:00 -0400
From: Steve Moyer <solutions@ix.gen.com>
Subject: Setting TARGET variable from Perl Script
Message-Id: <33C3D1A0.19F8@ix.gen.com>
How can you set the TARGET window from within a Perl Script?
Sam Choukri does it in his ColorMaker script at:
http://www.missouri.edu/~wwwtools/colormaker/index.html
I've sent him email but not yet received a response.
Thanks,
Steve Moyer
Synergy Solutions
http://gen.com/solutions
------------------------------
Date: Fri, 11 Jul 1997 08:14:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ivan Kohler <ivan@voicenet.com>
Subject: Re: shift on an empty array returns ( undef ) in a list context, not an empty list?
Message-Id: <Pine.GSO.3.96.970711080637.10200I-100000@kelly.teleport.com>
On Thu, 10 Jul 1997, Ivan Kohler wrote:
> In a scalar context, when shift'ing an empty array, shift returns the
> undefined value, as expected. In a list context, however, I was
> assuming (wrongly) that shift on an empty array would return an empty
> list. Instead, it returns a list with one scalar value (undef).
It's a general rule in Perl that a scalar value is promoted to a
one-element list when it's used in a list context. (This is a one-way
rule, though!)
It would be nice if, in a list context, shift would return an empty list
when the given list is empty. (Unfortunately, this could break old code.)
If that's all you want, I think that prototypes might make it possible to
redefine shift to do that. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 11 Jul 1997 15:33:17 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: Sorting
Message-Id: <5q5jnt$5c6@zk2nws.zko.dec.com>
I've been major disapointed w/ the sort in perl until I found this:
http://www.usenix.org/publications/perl/perl01.html
HOLA! I've spent a lot of time working ways around what I thought
was unforgivable oversight, and it was there all along!
This site also has other fine, real world examples and problem
solutions, HUZZA Hal Pomeranz !
W
------------------------------
Date: 11 Jul 1997 10:37:14 -0700
From: ranga <sveerara@cisco.com>
Subject: Re: Tracking running time??
Message-Id: <ls3rad5mqwl.fsf@sveerara-ultra.cisco.com>
You can get the total runtime in seconds by:
print time - $^T;
HTH,
----ranga <sveerara@cisco.com>
------------------------------
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 722
*************************************