[13464] in Perl-Users-Digest
Perl-Users Digest, Issue: 874 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 22 09:07:22 1999
Date: Wed, 22 Sep 1999 06:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938005512-v9-i874@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 22 Sep 1999 Volume: 9 Number: 874
Today's topics:
Re: Ad hominem (was Re: perl related question now!) (Anno Siegel)
Re: adduser/rmuser/passwd over socket? (Abigail)
Re: Anomymous Hash (Bart Lateur)
Re: Array length (Abigail)
batch <rasmusr@online.no>
Re: Be careful about using constants (Bart Lateur)
Re: Combining variables - newbie <nospam.newton@gmx.net>
Re: Getting results from system command (Sniper)
Re: Getting results from system command (Kragen Sitaker)
Re: I could use perldoc perlipctut (Abigail)
Re: I could use perldoc perlipctut (Kragen Sitaker)
Re: Interesting behavior of IO::Handle - bug? (Abigail)
Re: Looking for tools. <rhomberg@ife.ee.ethz.ch>
Re: newbie question...well kindof <madebeer@igc.apc.org>
Re: Newbie question (Abigail)
ODBC and sub-routines <jonnyace@magix.com.sg>
OOPS <jonnyace@magix.com.sg>
Re: perl related question now! (Anno Siegel)
Re: Preserving file name of uploaded file <krajzewicz@inx.de>
Re: Preserving file name of uploaded file (Bill Moseley)
Re: problem with the UNIX sum checksum command and unpa (Kragen Sitaker)
Re: Qns about passing by reference, etc <jonnyace@magix.com.sg>
Re: Qns about passing by reference, etc <jonnyace@magix.com.sg>
Re: Qns about passing by reference, etc <jonnyace@magix.com.sg>
Re: Qns about passing by reference, etc <jonnyace@magix.com.sg>
Re: Regex and my (Eric Bohlman)
Re: s/// and tr/// functions <ychampou@newbridge.com>
Re: s/// and tr/// functions <ychampou@newbridge.com>
Re: sort depth (Abigail)
Re: sort depth (Kragen Sitaker)
stopping a thread <jrl@ast.cam.ac.uk>
Re: stripping newlines out of a string (Abigail)
Re: stripping newlines out of a string (Kragen Sitaker)
Threads and win32 <jesus.escribanoNOqhSPAM@telefonica.es>
threads and win32 <jesus.escribanoNOheSPAM@telefonica.es>
Re: unsafe pipe opens (was:Some e-mails get sent, some (Bill Moseley)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Sep 1999 09:28:48 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Ad hominem (was Re: perl related question now!)
Message-Id: <7sa7gg$tqa$1@lublin.zrz.tu-berlin.de>
Elaine -HFB- Ashton <elaine@chaos.wustl.edu> wrote in comp.lang.perl.misc:
>Kragen Sitaker wrote:
> FE
> / \
> OC CO
> | | = ?
> OC CO
> \ /
> FE
Hemogoblin?
Anno
------------------------------
Date: 22 Sep 1999 02:26:00 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: adduser/rmuser/passwd over socket?
Message-Id: <slrn7uh192.db6.abigail@alexandra.delanet.com>
Song Kim (song@isot.com) wrote on MMCCXIII September MCMXCIII in
<URL:news:rugjip9klg725@corp.supernews.com>:
\\ I have a FreeBSD boxes, one running WWW and the other running SENDMAIL. I
\\ want to be able to adduser/rmuser/passwd from a NT box. Is the perl socket
\\ the right choice? Are there a port already available?
Does it matter what the FreeBSD run?
I guess you could use a Perl program that opens a socket for what you
want to do (there's no such thing as a "Perl socket"), but why involve
Perl? Just rsh (there are toolkits for NT that include rsh) to the box
and run adduser/rmuser/passwd.
Of course, this has little to do with Perl.
Abigail
--
perl -wlpe '}$_=$.;{' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 07:46:19 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Anomymous Hash
Message-Id: <37eb7d59.2144986@news.skynet.be>
Anders Wallin wrote:
> SWEDEN
> STOCKHOLM
> street1
> street2
>It seemed that the concept of anonymous hashes could be useful. I am
>however stuck getting this to work (both creating the hashes and
>printing them).
Picture this:
$street{'SWEDEN'}{'STOCKHOLM'}[0] = 'street1';
%street is an ordinary hash, but the keys are country names, and the
values are hash references. Those anonymous hashes all have cities as
keys, and array references as values. Those arrays contain the street
names.
Here's another way of adding them:
$country = 'SWEDEN';
$city = 'SWEDEN';
@streets = ('street1', 'street2');
foreach (@streets) { # street
# careful: %street must either be empty,
# or contain only array references when you do this
push @{$street{$country}{$city}}, $_;
}
and printing them:
foreach(@{$street{$country}{$city}}) { # the street array
print "$country $city: $_\n";
}
If you want to print them all:
foreach my $country (sort keys %street) { # that was easy
foreach my $city (sort keys %{$street{$country}}) {
# not as easy
foreach(@{$street{$country}{$city}}) {
# already familiar
print "$country $city: $_\n";
}
}
}
--
Bart.
------------------------------
Date: 22 Sep 1999 02:27:59 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Array length
Message-Id: <slrn7uh1cp.db6.abigail@alexandra.delanet.com>
Balasundar Raju (raju@bernie.mit.edu) wrote on MMCCXIII September
MCMXCIII in <URL:news:37E84AB7.115E3143@bernie.mit.edu>:
||
|| Could someone let me know how to find the length of an array - i.e. the
|| number
|| of elements in an array? Thanks,
Did you read the part of the manual that discusses arrays?
If so, what part of it didn't you understand? If you didn't,
why ask the question here?
Abigail
--
perl -wlne '}for($.){print' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 14:06:21 +0100
From: "Rasmus Rimestad" <rasmusr@online.no>
Subject: batch
Message-Id: <EO3G3.42$OH6.607@news1.online.no>
Hi. I've written a perl-script that needs to be executed the first day of
each month. I've made a function that loops and finds out which date it is,
but I can't figure out how to start the script.
Any help would be appreciated!
Rasmus Rimestad, first follower of the blue hen
| rasmusr@online.no | http://diktringen.cjb.net |
------------------------------
Date: Wed, 22 Sep 1999 07:46:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Be careful about using constants
Message-Id: <37ea7951.1113384@news.skynet.be>
Ilya Zakharevich wrote:
>Interesting: a couple of days ago I was thinking about AutoLoading
>with prototypes... This is not a simple idea.
>
>But it is close to user-defined-operators aka macros which I
>implemented this summer. When an unknown subroutine call is compiled,
>a call (at *compile* time) to some subroutine is made. This
>subroutine determines how to deal with the stuff.
>
>Hmm, on the second thought, this is *orthogonal* to my implementation
>of UDO/macros. With it the UDO/macros have fixed arity, and the
>compile-time-code is called *after* the arguments are parsed [so for
> $a (+) $b
>one *knows* that (+) takes 2 arguments and is infix of given priority].
Interesting approach. I think you're on to something. Maybe one should
have AUTOLOADing in two parts: the prototype, and the definition. So
sub F_SETFL ();
compiled normally, and
sub F_SETFL () {
4
}
autoloaded.
If the overhead of all the bare prototypes is still too high, your
operator-like compile-time autoloading could serve for that, while the
ordinary autoloading could serve to compile the actual call.
Or, could one compile a postponed compile time execution? Where the
compilations of the actual functions are queued towards the end of the
compilation phase, until when the whole script is compiled, and the
necessary functions are known?
-#-
Still, I have two objections to constants as functions:
A) constants should look like read-only variables, so that string
interpolation works with them
B) the value lookup overhead should happen at compile time; not a
function call every time you need the value.
C) if you need a constant array, the result looks even less like a
read-only variable:
constant_array(3)
instead of
$constant_array[3]
Maybe tied scalars/arrays could be used as a mechanism to prevent
changing the value of the constants. But, I expect the execution
overhead to be rather big.
--
Bart.
------------------------------
Date: Wed, 22 Sep 1999 09:17:42 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: Combining variables - newbie
Message-Id: <37E88296.155AB44D@gmx.net>
Philip 'Yes, that's my address' Newton wrote:
>
> $var3 = join ('', reverse($var2, "\40", $var1));
$var3 = join('s' & ',', $var1, $var2); # 's' for 'space' and ','
# because we're joining
Cheers,
Philip
------------------------------
Date: Wed, 22 Sep 1999 07:31:29 GMT
From: root@127.0.0.127 (Sniper)
Subject: Re: Getting results from system command
Message-Id: <37ef854b.59053176@news.bcandid.deja.com>
On Tue, 21 Sep 1999 19:11:50 GMT, root@127.0.0.127 (Sniper) wrote:
>Ok after reading the FAQ, llama book and some of the Camel book, I am
>delurking for help, Help!
>
>I want to get the results of a system command into a variable to do a
>match on, however I don't seem to be getting what I expect.
>
>$SYS_CALL = "dir /s";
>
>@Result = system ($SYS_CALL);
>
>$looking = grep /auto/,@Result;
>
>print ($looking);
>
>
>
>For example on a normal dos system, I would expect $looking to have
>autoexec.bat in it. however it gets 0 (zero)
>
>so for this example how do I get the line from the dir/s command that
>contains the autoexec.bat line into a variable, help, pointers, or
>what ever would be appreciated.
>
>Sniper
>
>Scorp 888 at hotmail dot com.
>
>
>--
>.
>"What's the difference between a nail, a screw and a bolt ?" the woodwork
>teacher asked the only girl in the class during the first day of school.
>She pondered the question for a moment, then replied, "Well, I can't rightly
>say as I know, 'cause I ain't never been 'bolted'."
Following up my own post, as I do more work on this the less I
understand !
This works
$Result = `dir /s`;
to get the results of the system command into $Result, however this
$SYS_CALL="dir /s";
$Result = system $SYS_CALL;
Doesn't !
I don't understand why doing it the variable way, so I can later make
the system call a subroutine, doesn't work.
Help !
Sniper
--
.
"What's the difference between a nail, a screw and a bolt ?" the woodwork
teacher asked the only girl in the class during the first day of school.
She pondered the question for a moment, then replied, "Well, I can't rightly
say as I know, 'cause I ain't never been 'bolted'."
------------------------------
Date: Wed, 22 Sep 1999 13:02:00 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Getting results from system command
Message-Id: <cr4G3.3150$QJ.173340@typ11.nn.bcandid.com>
In article <37ef854b.59053176@news.bcandid.deja.com>,
Sniper <root@127.0.0.127> wrote:
>Following up my own post, as I do more work on this the less I
>understand !
>
>This works
>
>$Result = `dir /s`;
>
>to get the results of the system command into $Result, however this
>
>$SYS_CALL="dir /s";
>$Result = system $SYS_CALL;
>
>Doesn't !
That's because that's not what system() does. system() and `` are two
different things.
>I don't understand why doing it the variable way, so I can later make
>the system call a subroutine, doesn't work.
`$SYS_CALL`
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 22 Sep 1999 02:43:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: I could use perldoc perlipctut
Message-Id: <slrn7uh293.db6.abigail@alexandra.delanet.com>
Martien Verbruggen (mgjv@comdyn.com.au) wrote on MMCCXIII September
MCMXCIII in <URL:news:beVF3.70$ml3.5445@nsw.nnrp.telstra.net>:
`` In article <AMOE3.18513$N77.1387885@typ11.nn.bcandid.com>,
`` kragen@dnaco.net (Kragen Sitaker) writes:
``
`` That is of course not true. If you have any blocking actions in your
`` program (reads from file systems, network accesses, DNS lookups to
`` name just a few), then parallellism can help tremendously in speeding
`` things up. If your program is not CPU bound, but I/O bound, then you
`` may see big increases. Especially if the I/O of the process uses more
`` than one device (NIC, multiple disks/controllers), you will see
`` speedups. Serialised, each access to the I/O subsystem would block the
`` whole chain of events. In parallell, one process may be blocked on one
`` I/O, while another is happily reading from or writing to another I/O
`` system.
You are only blocked by I/O if you are using blocking I/O. If you don't
want to be blocked by I/O, don't use blocking I/O.
The reason why you would want to use threads here is programming ease.
You can have the kernel (or library) worry about the sceduling, instead
of having to do it yourself. The downside is that it might be harder
to synchronize things, as you are no longer in control of when a context
switch occurs. You'll have to decide on a case by case bases whether
it's worth it or not.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 12:48:04 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: I could use perldoc perlipctut
Message-Id: <8e4G3.3139$QJ.171610@typ11.nn.bcandid.com>
In article <slrn7uh293.db6.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>You are only blocked by I/O if you are using blocking I/O. If you don't
>want to be blocked by I/O, don't use blocking I/O.
Assuming select() works properly on your system, you can even avoid
being blocked by I/O if you're using blocking I/O by only doing I/O
when you know it won't block.
>The reason why you would want to use threads here is programming ease.
>You can have the kernel (or library) worry about the sceduling, instead
>of having to do it yourself. The downside is that it might be harder
>to synchronize things, as you are no longer in control of when a context
>switch occurs.
Another downside is that switching contexts via the kernel is often
considerably slower than switching contexts by calling and returning.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 22 Sep 1999 03:29:24 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Interesting behavior of IO::Handle - bug?
Message-Id: <slrn7uh4vt.db6.abigail@alexandra.delanet.com>
Uri Guttman (uri@sysarch.com) wrote on MMCCXIII September MCMXCIII in
<URL:news:x7ln9z5x8t.fsf@home.sysarch.com>:
^^ >>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
^^
^^ KS> Filehandles
^^ KS> are brain-damaged.
^^
^^ so i wonder who is brain damaging her now?
Filehandles.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 10:33:20 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Looking for tools.
Message-Id: <37E89450.5DB64D14@ife.ee.ethz.ch>
Michael Stevens wrote:
> perl -d will also let you test a script debugging line by line.
> However, it doesn't have a very pleasant user interface. I've heard
> suggestions ddd will do perl debugging, but never actually investigate
> this. My personal debugging method is liberal use of the 'print' statement,
> as well as 'warn' and 'die'.
ddd is great if you have complex data. I have some stuff with lots of
nested objects. As every object contains a pointer back to the main
object, the Data::Dumper output for any variable is some 100 lines. ddd
(data display debugger) lets me nicely look at the data, as it's name
says. It still has some bugs, but I recommend it.
- Alex
------------------------------
Date: Wed, 22 Sep 1999 01:12:55 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: newbie question...well kindof
Message-Id: <APC&1'0'50775db8'337@igc.apc.org>
>i have found one weird side effect: if i print the hash like
> #inside a foreach loop
> print "$data{$tmp}...\n"
>then the output is weird, like the hash itself is corrupted but if i
>print it out using
>n print "$data{'USER'}...\n"
>[is does correct output]
Looks like you have good debugging instincts.
I advise you to carry it one step further and check what $tmp is.
print "${tmp}...\n";
If you do find unexpected stuff in tmp,
see perldoc -f chomp to get rid of \n.
$tmp =~ s/\s//g; will get rid of whitespace in $tmp, which may be
messing your program up.
HTH,
-Mike
------------------------------
Date: 22 Sep 1999 03:56:59 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Newbie question
Message-Id: <slrn7uh6jl.db6.abigail@alexandra.delanet.com>
kmonte (kmonte@columbus.rr.com) wrote on MMCCXIII September MCMXCIII in
<URL:news:mUYF3.15973$mo.523086@viper>:
&&
&& Be advised, you will get a lot of flames and holier-than-thou responses from
&& the gurus who forget what it is like to be a newbie,
*plonk*
Abigail
--
I was never a newbie.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 20:52:59 +0800
From: Jonathan Teo <jonnyace@magix.com.sg>
Subject: ODBC and sub-routines
Message-Id: <37E8D12A.8504A510@magix.com.sg>
I'm trying to write some generic sub-routines for connection using
Win32::ODBC, but just can't make it work. The (trimmed) code is
below. I've tried various alternatives: "return \$db;" instead of
"return $db", and dereferencing it in
the doSQL() call with "doSQL($$mydb...)" instead of "doSQL($mydb,...)".
The truth is, I'm totally lost.
The program fails at the sql() call:
Can't call method "sql" without a package or object reference at
c:\test\test1.pl line 33.
Could someone please tell me what I've done wrong?
Brgds Jonathan Teo
use Win32::ODBC;
my $mydb;
my $db;
my $odate;
exit if ($mydb = connectDB("nt10", "abcd", "efgh") == undef);
die "SQL failed!\n" if (doSQL($mydb, "select getdate() odate") < 0);
if ($mydb->FetchRow()) {
($odate) = $mydb->Data("odate");
}
print "$odate\n";
sub connectDB() {
my ($dsn, $uid, $pwd) = @_;
if (!($db = new Win32::ODBC("DSN=$dsn;UID=$uid;PWD=$pwd"))){
# print some log info here
return undef;
}else{
# print some log info here
return $db;
}
}
sub doSQL {
my ($db, $sql) = @_;
if ($db->sql($sql) ) {
print "Error: " . $db->Error() . "\n";
# print some log info here
return -1;
} else {
# print some log info here
return 0;
}
}
------------------------------
Date: Wed, 22 Sep 1999 20:55:03 +0800
From: Jonathan Teo <jonnyace@magix.com.sg>
Subject: OOPS
Message-Id: <37E8D1A7.74AFC026@magix.com.sg>
My Netscape was not configured properly and something went weird, and next thing I
know.
Apologies.
------------------------------
Date: 22 Sep 1999 09:36:01 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl related question now!
Message-Id: <7sa7u1$trp$1@lublin.zrz.tu-berlin.de>
David Cassell <cassell@mail.cor.epa.gov> wrote in comp.lang.perl.misc:
>Larry Rosler wrote:
>> "Her argument was ad hominem." Still a (predicate) adjective. I'm
>> beginning to think the 'adv' is just an error.
>
>You're just not thinking like an advertising exec. [Not
You misspelled "adverbising". HTH.
Anno
------------------------------
Date: Wed, 22 Sep 1999 12:09:50 +0200
From: Daniel Krajzewicz <krajzewicz@inx.de>
Subject: Re: Preserving file name of uploaded file
Message-Id: <37E8AAEE.2A7A259D@inx.de>
Makarand Kulkarni wrote:
>
> [ Burt Hwang wrote:
... snipped ...
> my $file = $CGIObject -> param('upload');
Is this equivalent to the use of the %ENV-array ??
If yes, what do I have to import to use this feature ?
thanks,
Daniel Krajzewicz
--
__________________________
< Daniel Krajzewicz >
>------------------------<
< krajzewicz@inx.de >
>------------------------<
< http://www.art-so-far.de >
>------------------------<
<__________________________>
------------------------------
Date: Wed, 22 Sep 1999 04:56:12 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Preserving file name of uploaded file
Message-Id: <MPG.125263b970a83fca989764@nntp1.ba.best.com>
Daniel Krajzewicz (krajzewicz@inx.de) seems to say...
> Makarand Kulkarni wrote:
> >
> > [ Burt Hwang wrote:
> ... snipped ...
> > my $file = $CGIObject -> param('upload');
>
> Is this equivalent to the use of the %ENV-array ??
> If yes, what do I have to import to use this feature ?
If I understand your question - NO not at all. 'param' here is indeed
getting a CGI passed parameter, but param is a method in the CGI module.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 22 Sep 1999 13:00:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: problem with the UNIX sum checksum command and unpack
Message-Id: <rp4G3.3148$QJ.172826@typ11.nn.bcandid.com>
In article <1dyisxt.x9e4crytcy1yN@twig.demon.co.uk>,
Fergus McMenemie <fergus@twig.demon.co.uk> wrote:
> I use the UNIX sum command as the basis of an ad-hoc
> scheme that keeps and eye on all SUID files. I liked
> the fact that perl contains an equivalent in built
> checksum command of its own (unpack). I could use both
> methods to check a file, and the value would be the
> same.
Checksums are good to see if a file has been accidentally corrupted by
physical equipment failure, say, due to noise on a modem line or a disk
failure. It is easy for an intelligent attacker to modify a file
without changing the checksum.
The same is true, by the way, of CRCs.
Presumably, if you're keeping an eye on suid files, you're interested
in defending against intelligent attackers.
> Has anybody got a perl algorithm equivalent to any of
> the other UNIX checksum commands
If you're doing what I think you're doing, you should be using a
cryptographically-strong hash function like MD5 or SHA-1. Some
versions of Unix come with a program called md5sum or something
similar.
There are Digest::MD5 and Digest::SHA modules available from CPAN.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 22 Sep 1999 20:27:36 +0800
From: Jonathan Teo <jonnyace@magix.com.sg>
To: Kragen Sitaker <kragen@dnaco.net>
Subject: Re: Qns about passing by reference, etc
Message-Id: <37E8CB38.8920A64D@magix.com.sg>
Kragen Sitaker wrote:
> In article <37E662EA.633F6DD6@pacific.net.sg>,
> Jonathan Teo <jonnyace@pacific.net.sg> wrote:
> >1. How do sub-routines change value of variables? eg, how would you
> >write something like chop(&)?
>
> @_ consists of aliases to the real variables. Modifying items in @_
> modifies the original variables.
>
> >2. If a sub-routine creates an object (eg $x = new
> >SomeModule::SomeObject), how do you pass it out to the calling routine
> >without
> > $x being a global variable.
>
> return $x;
>
> >3. How do you redirect STDERR, eg, so that "die" messages will go into a
> >file rather than console?
>
> open STDERR, ">a-file" or die "Couldn't open a-file: $!\n";
>
> This script outputs 'yeah! at - line 4.' to a-file.
>
> #!/usr/bin/perl -w
> open STDERR, ">a-file" or die "Couldn't open a-file: $!";
> warn "yeah!"
>
> >Any pointers would be much appreciated.
>
> char *x;
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> Mon Sep 20 1999
> 49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
Thanks for the help. OK with (1) altering of referenced arguments and (3)
redirection of STDERR.
(2) is still giving me problems. Will be posting another more specific example.
------------------------------
Date: Wed, 22 Sep 1999 20:28:13 +0800
From: Jonathan Teo <jonnyace@magix.com.sg>
To: Kragen Sitaker <kragen@dnaco.net>
Subject: Re: Qns about passing by reference, etc
Message-Id: <37E8CB5C.E0675D20@magix.com.sg>
Kragen Sitaker wrote:
> In article <37E662EA.633F6DD6@pacific.net.sg>,
> Jonathan Teo <jonnyace@pacific.net.sg> wrote:
> >1. How do sub-routines change value of variables? eg, how would you
> >write something like chop(&)?
>
> @_ consists of aliases to the real variables. Modifying items in @_
> modifies the original variables.
>
> >2. If a sub-routine creates an object (eg $x = new
> >SomeModule::SomeObject), how do you pass it out to the calling routine
> >without
> > $x being a global variable.
>
> return $x;
>
> >3. How do you redirect STDERR, eg, so that "die" messages will go into a
> >file rather than console?
>
> open STDERR, ">a-file" or die "Couldn't open a-file: $!\n";
>
> This script outputs 'yeah! at - line 4.' to a-file.
>
> #!/usr/bin/perl -w
> open STDERR, ">a-file" or die "Couldn't open a-file: $!";
> warn "yeah!"
>
> >Any pointers would be much appreciated.
>
> char *x;
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> Mon Sep 20 1999
> 49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
Thanks for the help. OK with (1) altering of referenced arguments and (3)
redirection of STDERR.
(2) is still giving me problems. Will be posting another more specific example.
------------------------------
Date: Wed, 22 Sep 1999 20:28:52 +0800
From: Jonathan Teo <jonnyace@magix.com.sg>
To: Kragen Sitaker <kragen@dnaco.net>
Subject: Re: Qns about passing by reference, etc
Message-Id: <37E8CB84.BAE3568B@magix.com.sg>
Kragen Sitaker wrote:
> In article <37E662EA.633F6DD6@pacific.net.sg>,
> Jonathan Teo <jonnyace@pacific.net.sg> wrote:
> >1. How do sub-routines change value of variables? eg, how would you
> >write something like chop(&)?
>
> @_ consists of aliases to the real variables. Modifying items in @_
> modifies the original variables.
>
> >2. If a sub-routine creates an object (eg $x = new
> >SomeModule::SomeObject), how do you pass it out to the calling routine
> >without
> > $x being a global variable.
>
> return $x;
>
> >3. How do you redirect STDERR, eg, so that "die" messages will go into a
> >file rather than console?
>
> open STDERR, ">a-file" or die "Couldn't open a-file: $!\n";
>
> This script outputs 'yeah! at - line 4.' to a-file.
>
> #!/usr/bin/perl -w
> open STDERR, ">a-file" or die "Couldn't open a-file: $!";
> warn "yeah!"
>
> >Any pointers would be much appreciated.
>
> char *x;
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> Mon Sep 20 1999
> 49 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
Thanks for the help. OK with (1) altering of referenced arguments and (3)
redirection of STDERR.
(2) is still giving me problems. Will be posting another more specific example.
------------------------------
Date: Wed, 22 Sep 1999 20:29:44 +0800
From: Jonathan Teo <jonnyace@magix.com.sg>
Subject: Re: Qns about passing by reference, etc
Message-Id: <37E8CBB8.C4B1665E@magix.com.sg>
Thanks for the help. OK with (1) altering of referenced arguments and (3)
redirection of STDERR.
(2) is still giving me problems. Will be posting another more specific example.
Kragen Sitaker wrote:
> In article <37E662EA.633F6DD6@pacific.net.sg>,
> Jonathan Teo <jonnyace@pacific.net.sg> wrote:
> >1. How do sub-routines change value of variables? eg, how would you
> >write something like chop(&)?
>
> @_ consists of aliases to the real variables. Modifying items in @_
> modifies the original variables.
>
> >2. If a sub-routine creates an object (eg $x = new
> >SomeModule::SomeObject), how do you pass it out to the calling routine
> >without
> > $x being a global variable.
>
> return $x;
>
> >3. How do you redirect STDERR, eg, so that "die" messages will go into a
> >file rather than console?
>
> open STDERR, ">a-file" or die "Couldn't open a-file: $!\n";
>
> This script outputs 'yeah! at - line 4.' to a-file.
>
> #!/usr/bin/perl -w
> open STDERR, ">a-file" or die "Couldn't open a-file: $!";
> warn "yeah!"
>
> >Any pointers would be much appreciated.
>
------------------------------
Date: 22 Sep 1999 06:06:54 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Regex and my
Message-Id: <7s9rlu$3be@dfw-ixnews16.ix.netcom.com>
whos_john_galt@my-deja.com wrote:
: I am going to research this more intensely, but why does:
:
: my $value="9876543210";
: my ($pubw)=$value=~/(\d{6})/;
$pubw is in list context here.
: print $pubw;
:
: produce: 987654
:
: BUT...
:
: $value="9876543210";
: $pubw=$value=~/(\d{6})/;
$pubw is in scalar context here.
: print $pubw;
:
: produce: 1
:
: I use these statements in a foreach loop, does the my force immediate
: evaluation and the 1 is generated by the loop?...but when I take the
: value of $value away, pubw appears undefined as if the 1 represents
: true..
Nope. It's the difference in context. If you took away the parens
around $pubw in the first example, it would behave like the second example.
------------------------------
Date: Wed, 15 Sep 1999 12:23:12 -0400
From: Yanick Champoux <ychampou@newbridge.com>
To: makau@multimania.com
Subject: Re: s/// and tr/// functions
Message-Id: <37DFC7F0.BC5B1D58@newbridge.com>
makau@multimania.com wrote:
> is it possible to do :
>
> s/\ \;/ /g;
> s/<BR>/\n/g;
>
> in one line?
Sure:
s/\ \;/ /g; s/<BR>/\n/g;
Yanick :)
--------------------------------------------------
|||| ||||| Yanick Champoux
||||\\|||| Analyst, Advanced Technology Support
||||\\\||| Newbridge Networks Corporation
||||\\\\|| More Info? http://www.newbridge.com
|||| \\\\| E-mail: ychampou@newbridge.com
||| ```` Phone: (613) 599-3600 x5423
--------------------------------------------------
------------------------------
Date: Wed, 15 Sep 1999 12:36:14 -0400
From: Yanick Champoux <ychampou@newbridge.com>
To: makau@multimania.com
Subject: Re: s/// and tr/// functions
Message-Id: <37DFCAFE.AD9EF974@newbridge.com>
> is it possible to do :
> s/\ \;/ /g;
> s/<BR>/\n/g;
> in one line?
Hullo again,
But, to be slightly less flippant than in my last mail, I guess that
what you really want to do is:
#! perl
my %tags = ( ' ' => ' ',
'<BR>' => "\n" );
while( <DATA> )
{
foreach my $key ( keys %tags )
{
s/$key/$tags{$key}/ig;
}
print;
}
__DATA__
Hello World!
<BR>(Cool, we are HTML free!)<BR>
__END__
It's more than one line, but it's fairly clear and easy to expand if you
want to add others tag conversions.
Cheers,
Yanick
--
--------------------------------------------------
|||| ||||| Yanick Champoux
||||\\|||| Analyst, Advanced Technology Support
||||\\\||| Newbridge Networks Corporation
||||\\\\|| More Info? http://www.newbridge.com
|||| \\\\| E-mail: ychampou@newbridge.com
||| ```` Phone: (613) 599-3600 x5423
--------------------------------------------------
------------------------------
Date: 22 Sep 1999 03:30:23 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: sort depth
Message-Id: <slrn7uh51p.db6.abigail@alexandra.delanet.com>
Dana Booth (dana@oz.net) wrote on MMCCXIII September MCMXCIII in
<URL:news:7s9dkb$8nd$0@216.39.141.21>:
"" Can anyone tell me how deep the sort function goes?
It is not how deep, but what y^&*#&87....NO CARRIER
--
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 12:42:34 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: sort depth
Message-Id: <_84G3.3131$QJ.169393@typ11.nn.bcandid.com>
In article <7s9ki0$qql$0@216.39.141.21>, Dana Booth <dana@oz.net> wrote:
>I should have been more specific... This is Perl 5 on an OpenBSD box. I have
>a textfile containing lines which I would like Perl to sort numerically.
>Each line is a 23 digit number. And my question would be, to how many digits
>is the sort function going to work?
If the numbers are right-justified in the column, sorting them as
strings will sort them correctly. But apparently you tried that and it
didn't work.
Sorting numerically converts the numbers to integers (if they'll fit)
or floating-point (otherwise). None of the computers I have around
here have 23 digits of precision in either integer or floating-point.
So you have to sort by strings.
If the numbers aren't right-justified, you can right-justify them
before sorting.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 22 Sep 1999 10:49:20 +0100
From: Jim Lewis <jrl@ast.cam.ac.uk>
Subject: stopping a thread
Message-Id: <37E8A620.C32FD02A@ast.cam.ac.uk>
I have a program where I am running a data processing pipeline on a
thread and
monitoring its progress in another one. Is there any way of sending a
signal to
the processing thread to stop it in its tracks if during the monitoring
I see something
is going wrong?
cheers, Jim
-------------------------------------------------------------------------------
Jim Lewis |
Cambridge Astronony Survey Unit | Phone (direct) 44-(0)1223-766652
Institute of Astronomy | (reception)
44-(0)1223-337548
Madingley Road | FAX
44-(0)1223-337523
Cambridge CB3 0HA |
UK |
e-mail jrl@ast.cam.ac.uk
-------------------------------------------------------------------------------
------------------------------
Date: 22 Sep 1999 04:19:52 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: stripping newlines out of a string
Message-Id: <slrn7uh7ui.db6.abigail@alexandra.delanet.com>
Quinn Coldiron (qcoldiro@thetoolhouse.com) wrote on MMCCXIII September
MCMXCIII in <URL:news:37E84332.87D6A2E9@thetoolhouse.com>:
<> I'm on RedHat 6.0 and am trying to write a Perl script that will strip
<> the newline character out of a string. Any help?
Hint: the Linux distribution your are using is irrelevant.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 22 Sep 1999 12:50:48 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: stripping newlines out of a string
Message-Id: <Ig4G3.3143$QJ.171857@typ11.nn.bcandid.com>
In article <slrn7uh7ui.db6.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>Quinn Coldiron (qcoldiro@thetoolhouse.com) wrote on MMCCXIII September
>MCMXCIII in <URL:news:37E84332.87D6A2E9@thetoolhouse.com>:
><> I'm on RedHat 6.0 and am trying to write a Perl script that will strip
><> the newline character out of a string. Any help?
>
>Hint: the Linux distribution your are using is irrelevant.
Unless you're trying to install AnyDBM. :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 22 Sep 1999 05:42:16 -0700
From: chusqui <jesus.escribanoNOqhSPAM@telefonica.es>
Subject: Threads and win32
Message-Id: <269584ac.73ef22df@usw-ex0102-012.remarq.com>
I have a question, sorry if this is off-topic.
How I can use threads in win32 ?(with PERL of course)
My system has now:
+W95
+Activestate 519
Which packages should I install?
And last:
It is a good idea spend time in learn a lot about threads?
or is better
to know deptly other features similars?
Lots of thanks and good luck for everyone
Jesus Escriabano
***ÿffffbf
------------------------------
Date: Wed, 22 Sep 1999 05:45:01 -0700
From: chusqui <jesus.escribanoNOheSPAM@telefonica.es>
Subject: threads and win32
Message-Id: <03676caf.74a6b66e@usw-ex0102-012.remarq.com>
I have a question, sorry if this is off-topic.
How I can use threads in win32 ?(with PERL of course)
My system has now:
+W95
+Activestate 519
Which packages should I install?
And last:
It is a good idea spend time in learn a lot about threads?
or is better
to know deptly other features similars?
Lots of thanks and good luck for everyone
Jesus Escriabano
***¿Alguien habla español aquí?****
* 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: Wed, 22 Sep 1999 05:58:23 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: unsafe pipe opens (was:Some e-mails get sent, some don't)
Message-Id: <MPG.1252724fd3aa52a2989765@nntp1.ba.best.com>
Michael Stevens (mstevens@ashre.demon.co.uk) seems to say...
> On Mon, 20 Sep 1999 18:52:30 -0700, Bill Moseley <moseley@best.com> wrote:
> >$adr =~ s/'/ /g;
> >Now, what am I missing (besides a safe pipe open)?
>
> A number of things pointed out by others. My recommendation is
> to pipe to 'sendmail -t',
Sorry, I didn't see what other people pointed out about $adr =~ s/'/ /g;
I know about using safe pipe opens. That's wasn't my question.
I'm working at a site where the manager has written a _bunch_ of scripts
using something similar to:
open(PROG, "$prog -s \"$query\" -d $database|");
I don't have access to or responsibility for these scripts, but I
couldn't let that go by. So, until they have time to rewrite the
scripts, I suggested to them to at least do this:
$query =~ tr/'/ /;
open(PROG, "$prog -s ' $query ' -d $database|") or die $!;
Which is an easy enough modification that they might actually make
the change.
Yes, yes, I know a pipe & exec is safer, or that I should only allow
'safe' characters in (one application needs to be able to pass
punctuation chars, for example). But I'm wondering about this hack to
use in the mean time.
I can't see how to backslash out of that, and I don't know the shell
well enough to know if any other characters that have special meaning
within single quotes. What has my tired old brain missed this time?
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 874
*************************************