[17349] in Perl-Users-Digest
Perl-Users Digest, Issue: 4771 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 31 06:05:38 2000
Date: Tue, 31 Oct 2000 03:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972990316-v9-i4771@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 31 Oct 2000 Volume: 9 Number: 4771
Today's topics:
Re: "chown" of symlink instead of linked file (Chris Fedde)
Re: "chown" of symlink instead of linked file (Tom Christiansen)
+ or - <jbou@bunker79.fsnet.co.uk>
Re: + or - (Frank Lettau)
Re: + or - <frnack.caron@infineon.com>
Re: [xchat] scripting <staeci@yahoo.com>
Re: Array of Associative Arrays? <lr@hpl.hp.com>
Re: ASP help, my eyes hurt...why doesn't this work (Tim Hammerquist)
Re: ASP help, my eyes hurt...why doesn't this work <rsmallwood@mindspring.com>
Auth DBI <thomas1280@my-deja.com>
binary files ronen_louvton@comverse.com
Re: binary files (Clay Irving)
Re: binary files (Martien Verbruggen)
Re: Bitreverse an integer (Logan Shaw)
Re: Bitreverse an integer <bart.lateur@skynet.be>
Re: CGI Perl vs. Java Servlets... (Incongruous Meowbot)
Re: class instance variables (Martien Verbruggen)
Client-side PerlScript question <babanov@earthlink.net>
Re: Comparing two files (Martien Verbruggen)
Re: grep vs. a subroutine to find an occurance of an el <harrisr@bignet.net>
Have I released all memory? <john@imining.com.tw>
Re: Have I released all memory? nobull@mail.com
Help Help fileevent in WINNT <ianmac@agilent.com>
Re: Help needed (Clay Irving)
Help with regex / parsing <martinf@gmx.de>
Re: Help with regex / parsing (Rafael Garcia-Suarez)
Re: Newbie question about hashes <MiGuenther@lucent.com>
Re: Newbie question about hashes nobull@mail.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 31 Oct 2000 05:05:25 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: "chown" of symlink instead of linked file
Message-Id: <pqsL5.36$Bf7.135468032@news.frii.net>
In article <39fe3697@cs.colorado.edu>,
Tom Christiansen <tchrist@perl.com> wrote:
>In article <1ejckhw.xd2wo61u8nyy0N%otto.wyss@bluewin.ch>,
>Otto Wyss <otto.wyss@bluewin.ch> wrote:
>>If I use "chown" specifying a symlink the owner of the linked file is
>>changed. Is there a switch or an option I could use, so that the owner
>>of the symlink itself is changed? Or is there anything so the owner of
>>both the symlink and the linked file is changed?
>>
>>How about if the symlink points to a symlink points to ... a file?
>
>What does the chown(2) manpage say?
>
>--tom
Is this a rhetorical question? Perl does not provide an interface to
lchown().
--
This space intentionally left blank
------------------------------
Date: 30 Oct 2000 22:24:24 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: "chown" of symlink instead of linked file
Message-Id: <39fe5788@cs.colorado.edu>
In article <pqsL5.36$Bf7.135468032@news.frii.net>,
Chris Fedde <cfedde@fedde.littleton.co.us> wrote:
>>>How about if the symlink points to a symlink points to ... a file?
>>What does the chown(2) manpage say?
>
>Is this a rhetorical question?
I'm trying to remind people how one learns the answer to these
things. Perl invokes the syscall. What the syscall does in border
cases is someting one must read up on one's own, and one must do
so in that syscall's manpage.
>Perl does not provide an interface to lchown().
True. However, as no syscall cares about the ownership of a symlink,
it is challenging to find an issue here. At worst, some program
has imposed its own semantics in an area that the kernel does not
address.
--tom
CHOWN(2) OpenBSD Programmer's Manual CHOWN(2)
NAME
chown, lchown, fchown - change owner and group of a file or link
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
int
chown(const char *path, uid_t owner, gid_t group);
int
lchown(const char *path, uid_t owner, gid_t group);
int
fchown(int fd, uid_t owner, gid_t group);
DESCRIPTION
The owner ID and group ID of the file (or link) named by path or refer-
enced by fd is changed as specified by the arguments owner and group. The
owner of a file may change the group to a group of which he or she is a
member, but the change owner capability is restricted to the super-user.
chown() clears the set-user-id and set-group-id bits on the file to pre-
vent accidental or mischievous creation of set-user-id and set-group-id
programs.
lchown() operates similarly to how chown() operated on older systems, and
does not follow symbolic links. It allows the owner and group of a sym-
bolic link to be set.
fchown() is particularly useful when used in conjunction with the file
locking primitives (see flock(2)).
One of the owner or group IDs may be left unchanged by specifying it as
-1.
RETURN VALUES
Zero is returned if the operation was successful; -1 is returned if an
error occurs, with a more specific error code being placed in the global
variable errno.
ERRORS
chown() or lchown() will fail and the file or link will be unchanged if:
[ENOTDIR] A component of the path prefix is not a directory.
[ENAMETOOLONG]
A component of a pathname exceeded {NAME_MAX} characters,
or an entire path name exceeded {PATH_MAX} characters.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a component of the path
prefix.
[ELOOP] Too many symbolic links were encountered in translating the
pathname.
[EPERM] The effective user ID is not the super-user.
[EROFS] The named file resides on a read-only file system.
[EFAULT] path points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the
file system.
fchown() will fail if:
[EBADF] fd does not refer to a valid descriptor.
[EINVAL] fd refers to a socket, not a file.
[EPERM] The effective user ID is not the super-user.
[EROFS] The named file resides on a read-only file system.
[EIO] An I/O error occurred while reading from or writing to the
file system.
SEE ALSO
chgrp(1), chmod(2), flock(2), chown(8)
STANDARDS
The chown() function is expected to conform to IEEE Std1003.1-1988
(``POSIX'').
HISTORY
The fchown() function call appeared in 4.2BSD.
The chown() and fchown() functions were changed to follow symbolic links
in 4.4BSD.
The lchown() function was added to OpenBSD due to the above.
OpenBSD 2.6 January 25, 1997 2
------------------------------
Date: Tue, 31 Oct 2000 10:17:27 -0000
From: "James Boulter" <jbou@bunker79.fsnet.co.uk>
Subject: + or -
Message-Id: <8tm689$igc$1@newsg4.svr.pol.co.uk>
Dear all,
I would like to convert a variable with a number like -14 to 14. How can
this be done.
Any help would be much appreciated.
James
------------------------------
Date: 31 Oct 2000 10:56:02 GMT
From: killing_fountains@gmx.de (Frank Lettau)
Subject: Re: + or -
Message-Id: <8FDE70B3Ckillingfountainsgmxd@137.226.144.7>
jbou@bunker79.fsnet.co.uk (James Boulter) wrote in comp.lang.perl.misc:
>Dear all,
>
>I would like to convert a variable with a number like -14 to 14. How can
>this be done.
perldoc -f abs, if you always want positive values.
If you just want to swap the +/-:
$a *= -1;
cheers,
Frank
--
Frank Lettau <killing_fountains@gmx.de>
"Sometimes truth is stranger than fiction"
- Brett Gurewitz
------------------------------
Date: Tue, 31 Oct 2000 11:56:51 +0100
From: Caron Franck <frnack.caron@infineon.com>
Subject: Re: + or -
Message-Id: <39FEA572.6C2101E5@infineon.com>
let try
$a =~ s/^\-(\d+)$/$1/ ;
Where $a is your variable.
This will work even if your var is not a number.But something like :
$a = ($a <0) ? -$a : $a;
will work for $a numerical but if a is not a number (i.e. $a = 'toto') you
will have a runtime error message.
-- Franck
James Boulter wrote:
> Dear all,
>
> I would like to convert a variable with a number like -14 to 14. How can
> this be done.
>
> Any help would be much appreciated.
>
> James
------------------------------
Date: Tue, 31 Oct 2000 08:16:39 GMT
From: "Darrin Mison" <staeci@yahoo.com>
Subject: Re: [xchat] scripting
Message-Id: <HdvL5.6234$Tq6.58614@news-server.bigpond.net.au>
You don't actually 'have' to know what modules are to script in
xchat. I'm only basically aware that modules exist and that they
extend the fuctions available to perl. I started xchat scripting about
a week ago. All the mistakes I made where the result of stupid
coding errors.
> Hi, I am looking for a well-done, complete xchat scriipting tutorial.
> The one that is possible to find on www.xchat.org is really really bad:
> mostly, I need to know what modules do!
try this to get an idea...
#!/usr/bin/perl
#everyones favourite, helloworld
IRC::print("Hello World...\n"); #only you'll see this
IRC::command("Hello World...\n"); #channel sees this
IRC::command("/me says Hello World...\n"); #channel sees this too
reading the raw log window is handy for debugging
------------------------------
Date: Tue, 31 Oct 2000 00:22:00 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Array of Associative Arrays?
Message-Id: <MPG.146820fec92aee98ae85@nntp.hpl.hp.com>
In article <slrn8vsd8n.p9p.tjla@thislove.dyndns.org>,
tjla@guvfybir.qlaqaf.bet says...
...
> ... What I think you want to do is store a reference to a hash.
> You can do this is at least two ways:
>
> 1)
>
> $DataMatrix[$reccount] = {%TokenArray};
This creates a copy of %TokenArray, which can then change but the copied
hash won't change.
> 2)
>
> $DataMatrix[$reccount] = \%TokenArray;
>
> The second is probably better because it doesn't flatten the key/values
> out into a list before making the reference, as the first does (I
> think).
This creates a reference to the existing %TokenArray, not a copy.
Unless %TokenArray is dynamically allocated (by my()), further elements
of @DataMatrix may refer to the same hash, undoubtedly not what is
wanted.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 31 Oct 2000 05:04:12 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: ASP help, my eyes hurt...why doesn't this work
Message-Id: <slrn8vslki.1a0.tim@degree.ath.cx>
Russell Smallwood <rsmallwood@mindspring.com> wrote:
> I'm now in my 2nd hour staring at the screen trying to figure out why
> this doesn't work:
> <SCRIPT LANGUAGE=Perlscript RUNAT=Server>
>
> sub goldtime{
[snip]
> }
> </SCRIPT>
>
> <INPUT type="hidden" name="goldtime" value="<% goldtime %>">
>
> Anybody have it in their heart to help a newbie? I am basing this sub
> call on the example vbs-pl-param.aap that lives in the perl/eg
> directory. I have stared and stared....
In the example page you're referring to the PerlScript function foobar()
is called (in VBScript context) using parentheses, indicating VBScript
treats PerlScript subs as _functions_ and not _subroutines_. VB subs do
not require parenthese (an in fact, cannot have parens), while VB
functions both require parens. This is most likely due to the fact that
VB subs do not return a value, while Perl subs _do_, even if it's just
undef.
Long-winded explanation aside, could it be that you're missing parens?
eg:
<INPUT type="hidden" name="goldtime" value="<% goldtime() %>">
--
-Tim Hammerquist <timmy@cpan.org>
A liar should have a good memory.
-- Quintilian
------------------------------
Date: Tue, 31 Oct 2000 06:53:26 GMT
From: Russell Smallwood <rsmallwood@mindspring.com>
Subject: Re: ASP help, my eyes hurt...why doesn't this work
Message-Id: <MPG.14683943829d3da198968e@news.giganews.com>
In article <slrn8vslki.1a0.tim@degree.ath.cx>, tim@degree.ath.cx says...
> Russell Smallwood <rsmallwood@mindspring.com> wrote:
> > I'm now in my 2nd hour staring at the screen trying to figure out why
> > this doesn't work:
>
> > <SCRIPT LANGUAGE=Perlscript RUNAT=Server>
> >
> > sub goldtime{
> [snip]
> > }
> > </SCRIPT>
> >
> > <INPUT type="hidden" name="goldtime" value="<% goldtime %>">
<snip>
Tim Replys----
> In the example page you're referring to the PerlScript function foobar()
> is called (in VBScript context) using parentheses, indicating VBScript
> treats PerlScript subs as _functions_ and not _subroutines_. VB subs do
> not require parenthese (an in fact, cannot have parens), while VB
> functions both require parens. This is most likely due to the fact that
> VB subs do not return a value, while Perl subs _do_, even if it's just
> undef.
>
> Long-winded explanation aside, could it be that you're missing parens?
> eg:
>
> <INPUT type="hidden" name="goldtime" value="<% goldtime() %>">
Thanks I will try this,
Russell
>
------------------------------
Date: Tue, 31 Oct 2000 10:01:58 GMT
From: Tom Tom <thomas1280@my-deja.com>
Subject: Auth DBI
Message-Id: <8tm5al$bpp$1@nnrp1.deja.com>
I shall try a different tack.
Does anyone know where I can find some docs on writing Auth DBI
with Perl for Apache? In particular, dealing with handles and
connections to the web server?
--
Cheers,
Tom
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 31 Oct 2000 09:04:07 GMT
From: ronen_louvton@comverse.com
Subject: binary files
Message-Id: <8tm1u5$9d9$1@nnrp1.deja.com>
I need a script that handles reading and writing from a binary file .
The binary file represents a struct (In C ).
Thanks ,Ronen
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 31 Oct 2000 09:43:10 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: binary files
Message-Id: <slrn8vt51e.84.clay@panix3.panix.com>
On Tue, 31 Oct 2000 09:04:07 GMT, ronen_louvton@comverse.com
<ronen_louvton@comverse.com> wrote:
>I need a script that handles reading and writing from a binary file .
>The binary file represents a struct (In C ).
A good place to start is the documentation for pack and unpack.
--
Clay Irving <clay@panix.com>
Crime doesn't pay... does that mean my job is a crime?
------------------------------
Date: Tue, 31 Oct 2000 21:26:39 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: binary files
Message-Id: <slrn8vt7iv.ac5.mgjv@martien.heliotrope.home>
On Tue, 31 Oct 2000 09:04:07 GMT,
ronen_louvton@comverse.com <ronen_louvton@comverse.com> wrote:
> I need a script that handles reading and writing from a binary file .
> The binary file represents a struct (In C ).
This is exactly why Perl has the pack and unpack functions. Check your
perlfunc documentation to find out more about them.
Martien
--
Martien Verbruggen |
Interactive Media Division | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: 31 Oct 2000 00:20:47 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Bitreverse an integer
Message-Id: <8tlobv$3sa$1@provolone.cs.utexas.edu>
In article <8tjeif$e8q$1@lublin.zrz.tu-berlin.de>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>Logan Shaw <logan@cs.utexas.edu> wrote in comp.lang.perl.misc:
>>In article <8tev8c$ap1$1@lublin.zrz.tu-berlin.de>,
>>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>>>The one possible drawback is that it relies on a fixed integer size
>>>(of 32 bits).
>>
>>That is easy enough to fix. If you write it in Perl like this:
>>
>> $twiddles =
>> [
>> [ 0xffff0000, 0x0000ffff, 16 ],
>> [ 0xff00ff00, 0x00ff00ff, 8 ],
>> [ 0xf0f0f0f0, 0x0f0f0f0f, 4 ],
>> [ 0xcccccccc, 0x33333333, 2 ],
>> [ 0xaaaaaaaa, 0x55555555, 1 ],
>> ];
>>
>> foreach $twiddle (@$twiddles)
>> {
>> $x = (($x & $twiddle->[0] >> $twiddle->[2])
>> | ($x & twiddle->[1] >> $twiddle->[2]));
>> }
>>
>>Then, different values of $twiddles will make it work for different bit
>>widths. Since you typically won't use very many different bit widths,
>>it's reasonable to dynamically compute $twiddles and cache the
>>results.
>
>Ah, dynamic twiddle generation, very promising concept. It does
>bring back a lookup table though.
I'll let you know when I come up with a closed form for
n-1
__
\ k
/_ 4
k=0
Once I can do that, then I can create a bit string consisting of
alternating 1's and 0's, and I think I can build the rest of the stuff
easily enough on the fly from bitmasks.
However, this isn't going to be remotely fast. The lookup table really
is better, IMHO. It's very small for each bit width, and you don't
need but a few of them around.
Actually, if I were doing it for real, I wouldn't create the lookup
tables. Instead, I'd use eval to build a "dynamically hardcoded"
anonymous subroutine that does the whole computation for a given bit
width.
- Logan
------------------------------
Date: Tue, 31 Oct 2000 08:52:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bitreverse an integer
Message-Id: <vk0tvs0taci86r89ouh87gsbcrnkkj2ldd@4ax.com>
Logan Shaw wrote:
>>> foreach $twiddle (@$twiddles)
>>> {
>>> $x = (($x & $twiddle->[0] >> $twiddle->[2])
>>> | ($x & twiddle->[1] >> $twiddle->[2]));
>>> }
That ain't right. This uses ">>" twice, while it should be "<<" once,
and ">>" once.
>>Ah, dynamic twiddle generation, very promising concept. It does
>>bring back a lookup table though.
>
>I'll let you know when I come up with a closed form for
>
> n-1
> __
> \ k
> /_ 4
>
> k=0
>
>Once I can do that, then I can create a bit string consisting of
>alternating 1's and 0's, and I think I can build the rest of the stuff
>easily enough on the fly from bitmasks.
Closed form? Hmmm...
for(my $i=1; $i<32; $i<<=1) {
my $acc = 1;
for(my $j= 0; $j<32; $j += 2*$i) {
$acc |= 1<<$j;
}
$acc *= (1<<$i)-1;
printf "%032b %032b %2d\n", $acc, ~$acc, $i;
}
-->
01010101010101010101010101010101 10101010101010101010101010101010 1
00110011001100110011001100110011 11001100110011001100110011001100 2
00001111000011110000111100001111 11110000111100001111000011110000 4
00000000111111110000000011111111 11111111000000001111111100000000 8
00000000000000001111111111111111 11111111111111110000000000000000 16
>Actually, if I were doing it for real, I wouldn't create the lookup
>tables. Instead, I'd use eval to build a "dynamically hardcoded"
>anonymous subroutine that does the whole computation for a given bit
>width.
Me too. I'd rather write code that generates Perl code to include
inline, than any form of loop. It needn't even be part of *this*
program.
for(my $i=1; $i<32; $i<<=1) {
my $acc = 1;
for(my $j= 0; $j<32; $j += 2*$i) {
$acc |= 1<<$j;
}
$acc *= (1<<$i)-1;
printf "\$x = ((\$x & 0x%08X)<<$i)|((\$x & 0x%08X)>>$i);\n",
$acc, ~$acc;
}
-->
$x = (($x & 0x55555555)<<1)|(($x & 0xAAAAAAAA)>>1);
$x = (($x & 0x33333333)<<2)|(($x & 0xCCCCCCCC)>>2);
$x = (($x & 0x0F0F0F0F)<<4)|(($x & 0xF0F0F0F0)>>4);
$x = (($x & 0x00FF00FF)<<8)|(($x & 0xFF00FF00)>>8);
$x = (($x & 0x0000FFFF)<<16)|(($x & 0xFFFF0000)>>16);
--
Bart.
------------------------------
Date: 31 Oct 2000 00:06:19 -0500
From: meowbot@meowing.net (Incongruous Meowbot)
Subject: Re: CGI Perl vs. Java Servlets...
Message-Id: <878zr5r450.fsf@litterbox.meowing.net>
Ryan Bedford <ryanb@one.net> wrote:
> All things being equal which is faster? CGI Perl or Java Servlets?
¿Que es mas macho, pineapple o knife?
--
"We'll cut off his head, cut off his skin, cut off his two toes, then we'll
cook him." - Stinky T. Davis
------------------------------
Date: Tue, 31 Oct 2000 20:50:36 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: class instance variables
Message-Id: <slrn8vt5fc.ac5.mgjv@martien.heliotrope.home>
On Mon, 30 Oct 2000 21:02:53 GMT,
dsevans@my-deja.com <dsevans@my-deja.com> wrote:
> hello,
>
> in the System_Probes package/module/file
> are a collection of subs. one is called
> read_config and it does this at one point:
>
> push @{ $self->{'trap_dest'} }, 123.23.23.123";
This doesn't compile.
> theres another sub send_trap that does this:
> foreach ( @{$self->{'trap_dest'}} ) {
> # whatever
> }
>
> it doesn't work.
> if i call this hash key 'trapdest',
> it works.
Nonsense.
#!/usr/local/bin/perl -wl
use strict;
my $self = {};
for (1 .. 10) { push @{$self->{trap_dest}}, "123.123.123.$_" }
for (@{$self->{trap_dest}}) { print }
works fine. You must be doing something else wrong. Without you
showing us the real code, we can't even begin to guess.
But, before you send us 4000 lines of code, reduce your problem to a
very small self-contained piece of code that shows the problem. I've
found in the past that when you prepare code like that, you will find
the problem.
Martien
--
Martien Verbruggen |
Interactive Media Division | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd. | bundled with your Microsoft product.
NSW, Australia |
------------------------------
Date: Tue, 31 Oct 2000 08:15:10 GMT
From: "Alexander Babanov" <babanov@earthlink.net>
Subject: Client-side PerlScript question
Message-Id: <icvL5.4482$Pw6.277812@newsread1.prod.itd.earthlink.net>
Hi, all,
I can't dig a structure of $window->document object :-( Could someone
help me with an example of manipulating some HTML tag via PerlScript?
Indeed, _any_ client-side PerlScript examples/links are greatly appriciated.
Thanks in advance!
Alexander Babanov <babanov@earthlink.net>
Department of Economics, University of Minnesota
------------------------------
Date: Tue, 31 Oct 2000 21:08:27 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Comparing two files
Message-Id: <slrn8vt6gr.ac5.mgjv@martien.heliotrope.home>
On 30 Oct 2000 13:12:20 -0700,
Tom Christiansen <tchrist@perl.com> wrote:
>
> Right--such as in that case. File::Find does so much more.
> It's really more like fts(3) in many senses.
You mean the BSD fts_open and related functions? It's sorely lacking
from many SYSV based systems and half-breeds like GNU/Linux.
Hmmm. I think File::Find is actually sort of between find(1) and fts(3).
The model of how the calls are made in File::Find (visit each file in
succession and call a callback function which can filter) is more like
the way find(1) works. However, it's as low-level as fts(3) in the way
that it doesn't provide a thousand and one built-in filters.
I must say however that I am guilty of using find(1) above File::Find
most of the time, but mainly from the command line. I haven't really
found many uses yet for directory traversal inside of a program.
> In article <x7y9z6i1ej.fsf@home.sysarch.com>,
> Uri Guttman <uri@sysarch.com> wrote:
> >and we will never use `ls`
> >over a file glob or readdir. now deciding when comparing files whether
And I would never use a glob over a readdir, unless I could be
absolutely certain that the code wouldn't run under pre-5.6.0 perls. But
that is mainly because a readdir with a grep is only slightly larger,
and no more error prone than a glob or ls. More complex things make the
use of external programs more attractive.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Tue, 31 Oct 2000 01:15:26 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: grep vs. a subroutine to find an occurance of an element in a list
Message-Id: <svsoqrshbb6a12@corp.supernews.com>
Steven Smolinski <sjs@yorku.ca> wrote in message
news:slrn8vn6q0.ib.sjs@ragnar.sympatico.ca...
> Randy Harris <harrisr@bignet.net> wrote:
> > Tom Christiansen <tchrist@perl.com> wrote in message
> > news:39fb7a01@cs.colorado.edu...
>
> > > [...] Perl comes with manpages. If
you
> > > don't have them trivially available, then you don't have a proper
> > > installation and should immediately fire your system administrator
> > > for gross negligence.
> >
> > Now wait a darned minute, I resemble that remark. I'm one of those
> > system administrators whose firing you are advocating. I have lots
of
> > systems that have the perl command processor but no perldoc and no
Perl
> > manpages, because that is the way the OS comes from HP. I'm not
> > suggesting these can't be added, but I think gross negligence is a
bit
> > of an exaggeration.
>
> If it's a vanilla HP install, it may very well have a carcass of a
camel
> (version 4) rather than a live, breathing one.
>
> I think in that case you keep your job; we ought to start sacking
people
> at HP who think it's funny to package a buggy, eight year-old version
of
> software that they can acquire for free.
>
> Come to think of it, my latest AIX machine had a ksh that wasn't even
> ksh '93 compliant...
>
> Steve
Where this becomes a problem for me, is I need to write programs that
can be run on any of several hundred systems. Many of them have been
set up by me, but not all. So, I can't even put a newer Perl on the
system I use for development, since I can't afford to write programs
that won't run on all of our systems. Something of a dilemma. Tom
might not agree, but I see little alternative. Consequently, I am often
forced to use other, albeit less capable tools, usually Korn shell.
Randy
------------------------------
Date: Tue, 31 Oct 2000 11:49:03 +0800
From: "John" <john@imining.com.tw>
Subject: Have I released all memory?
Message-Id: <8tlfoo$fko@netnews.hinet.net>
Hi:
I have a hash %test.
$test{"aaa"}[0][0]="a";
$test{"aaa"}[0][1]="b";
$test{"bbb"}[0][0]="c";
$test{"bbb"}[0][1]="d";
Will
delete $test{"aaa"};
or
%test=();
release all memory of 1st and 2nd level arrays?
Thanks.
John Hsieh
john@imining.com.tw
------------------------------
Date: 31 Oct 2000 08:46:45 +0000
From: nobull@mail.com
Subject: Re: Have I released all memory?
Message-Id: <u9aebltk8g.fsf@wcl-l.bham.ac.uk>
"John" <john@imining.com.tw> writes:
> $test{"aaa"}[0][0]="a";
> $test{"aaa"}[0][1]="b";
> $test{"bbb"}[0][0]="c";
> $test{"bbb"}[0][1]="d";
>
> Will
> delete $test{"aaa"};
> or
> %test=();
> release all memory of 1st and 2nd level arrays?
Yes, you release it back to the pool avialable for Perl. Perl does
not release it back to the OS.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 31 Oct 2000 09:16:43 -0000
From: "Ian Mackenzie" <ianmac@agilent.com>
Subject: Help Help fileevent in WINNT
Message-Id: <39fe8dd6$1@hpsqftk>
Hi , I have a PerlTk program that uses sockets with the fileevent
set to call the callback sub when the socket filehandle is readable,
this works fine in unix but in WINNT the filevent calls ths callback
sub even when there is no connection to the socket filehandle
socket section :
############################################################################
###
####
#
# Set up socket connect to port 3001
#
############################################################################
####
####
socket(SERVER,PF_INET,SOCK_STREAM, getprotobyname('tcp'));
setsockopt(SERVER,SOL_SOCKET,SO_REUSEADDR,1);
$addr = sockaddr_in(3001,inet_aton($hostname));
bind(SERVER,$addr)
or die "Could not bind to port\n";
listen(SERVER,SOMAXCONN)
or die "Could not listen to port\n";
$|=1;
Fileevent section :
############################################################################
####
######
# set up main_frame file_event to enables external commands to take action
#
############################################################################
####
#####
$main_frame->fileevent(SERVER,'readable',[\&parse_socket]);
The parse_socket sub is called immediatly, i.e the event does not wait until
there is activity on the socket filehandle SERVER
Any clues anyone, I am using perl 5.6 from ActivePerl
------------------------------
Date: 31 Oct 2000 09:52:53 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Help needed
Message-Id: <slrn8vt5jl.84.clay@panix3.panix.com>
On Mon, 30 Oct 2000 17:40:00 GMT, Michael Pucci <puccim2@uofs.edu> wrote:
> I am trying to set up a site that will required username/password
>authenication. Once logged in, they will have access to there info
>stored in a database and special things that only members can do.
>Also, I would like to set up different triers of password protection
>(member and admins). The free web host provider I use is
>www.mycgiserver.com they allow full access to cgi-bin but don't support
>mysql. I have no idea how to do this and I have searched sites but I
>can't find what I exactly need. If anyone can help, PLEASE contact me
>at puccim2@uofs.edu. Also, if anyone knows any free web providers that
>would be better suited for me please let me know. Thanks so much!
You posted in the wrong newsgroup -- This is a Perl newsgroup, not the
alt.where.is.the.free.web.provider newsgroup.
--
Clay Irving <clay@panix.com>
Tis better to be thought a fool, then to open your mouth and remove
all doubt.
------------------------------
Date: Tue, 31 Oct 2000 09:07:10 +0100
From: Martin Fischer <martinf@gmx.de>
Subject: Help with regex / parsing
Message-Id: <39FE7DAE.7983A57E@gmx.de>
Hi,
I'm trying to solve a parsing problem for a simple macro language.
The language basically has two constructs:
1. <VAR="value"> to assign values, and
2. <FUNCTION( "value" )> to call a subroutine.
I'd like to parse these statements with PERL but wasn't completely
successful. I need the first keyword eg. FUNCTION in one variable and
the value or parameters in another.
The best I came up with is
/^<([A-Z]*)(=|\()([\w\"]*)\)?>$/
The result is that $1 contains the keyword and $3 the value / parameter.
That far this is ok. But this regex doesn't recognize ill-behaved source
like
<VAR="value")> or <FUNCTION( "value">
To correct this, I've tried the following:
/^<([A-Z]*)(=([\w\"]*)>|\(([\w\"]*)\)>)$/
but that didn't work. I suppose it's a problem of the nested brackets
but am not sure.
How can I make that work ?
Any help or hints are welcome.
Regards,
Martin
------------------------------
Date: Tue, 31 Oct 2000 08:35:21 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Help with regex / parsing
Message-Id: <slrn8vt15k.k1s.rgarciasuarez@rafael.kazibao.net>
Martin Fischer wrote in comp.lang.perl.misc:
>Hi,
>
>I'm trying to solve a parsing problem for a simple macro language.
>
>The language basically has two constructs:
>
>1. <VAR="value"> to assign values, and
>2. <FUNCTION( "value" )> to call a subroutine.
>
>I'd like to parse these statements with PERL but wasn't completely
>successful. I need the first keyword eg. FUNCTION in one variable and
>the value or parameters in another.
>
>The best I came up with is
>
>/^<([A-Z]*)(=|\()([\w\"]*)\)?>$/
>
>The result is that $1 contains the keyword and $3 the value / parameter.
>That far this is ok. But this regex doesn't recognize ill-behaved source
>like
>
><VAR="value")> or <FUNCTION( "value">
You mean that your regex does recognize those constructs, don't you?
>To correct this, I've tried the following:
>
>/^<([A-Z]*)(=([\w\"]*)>|\(([\w\"]*)\)>)$/
>
>but that didn't work. I suppose it's a problem of the nested brackets
>but am not sure.
>
>How can I make that work ?
Why not use two regexps?
/^<(VAR)=\s*("\w*")\s*$/ || /^<(FUNCTION)\(\s*("\w*")\s*\)>$/
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Tue, 31 Oct 2000 10:20:01 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: Newbie question about hashes
Message-Id: <8tm2r1$lf4@nntpb.cb.lucent.com>
Hi Chris the way you place the $s in your hash is truly a bit incorrect.
the way you do
%sessionKey =($s,0);
says the complete hash consist of one element Key= $s Value= 0
the right way to add a Key and value is
$sessionKey{$s}=0;
$HashName{Key}=Value;
Michael
Lucent Technologies Netcare (http://www.lucent.com/netcare/)
Michael Günther (miguenther@lucent.com) - Mobile: +49 (0)173 6513678
MURPHY ALWAYS WINS
------------------------------
Date: 31 Oct 2000 08:26:15 +0000
From: nobull@mail.com
Subject: Re: Newbie question about hashes
Message-Id: <u98zr5tk7g.fsf@wcl-l.bham.ac.uk>
Chris Kantarjiev <cak@putzl.com> writes:
> I'm trying to use hashes to keep track of session keys across multiple
> socket connections (among other things). Even though I think I'm
> creating several entries in the hash, the only key that's defined at the
> end is the last one I put in.
> %sessionKey = ($s, 0);
This line is executed inside your loop and throws away any previous
content of %sessionKey.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 4771
**************************************