[19913] in Perl-Users-Digest
Perl-Users Digest, Issue: 2108 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 10 18:06:03 2001
Date: Sat, 10 Nov 2001 15:05:10 -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: <1005433509-v10-i2108@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 10 Nov 2001 Volume: 10 Number: 2108
Today's topics:
Re: apply chown() to a symlink <grinsefisch@gmx.ch>
Re: apply chown() to a symlink <wwonko@rdwarf.com>
color coded traceroute <kteegirl24@hotmail.com>
Re: color coded traceroute (David Efflandt)
Re: converting ^M characters to \n (J.B. Moreno)
Re: converting ^M characters to \n <flavell@mail.cern.ch>
help - using regular expressions with conditional while (james)
Re: help - using regular expressions with conditional w <mbudash@sonic.net>
Re: help - using regular expressions with conditional w (Tad McClellan)
Re: help with hashref <tinamue@zedat.fu-berlin.de>
Re: help with hashref <jens@irs-net.com>
History Event <chpshi@stonix.com>
Re: how to print out every second value of an array <Laocoon@eudoramail.com>
Re: how to print out every second value of an array (Tad McClellan)
How to query or discover a script's filename??? <no_spam.yet_another_apprentice@hotmail.com>
Re: How to query or discover a script's filename??? <jens@irs-net.com>
Re: How to query or discover a script's filename??? (David Efflandt)
Re: How to query or discover a script's filename??? (F. Xavier Noria)
Re: md5 and hashrefs <bart.lateur@skynet.be>
module to help change login shell (no..chsh is not avai <none@nothere.please.net>
Re: Perl vs. Active Perl <djberg96@hotmail.com>
Re: Perl vs. Active Perl <tim@vegeta.ath.cx>
Perl/DBI update q <mikecook@cigarpool.com>
Re: Perl/DBI update q (Steven Edwards)
Re: regular expresion (Steven Edwards)
Re: regular expresion (Tad McClellan)
Re: regular expresion (Steven Edwards)
Re: Regular Expressions <jurgenex@hotmail.com>
Re: Regular Expressions <jurgenex@hotmail.com>
Re: system() and exec() (Tad McClellan)
Re: system() and exec() (F. Xavier Noria)
Re: which is faster? =1 or ++ (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 10 Nov 2001 16:41:23 +0100
From: Radu Muschevici <grinsefisch@gmx.ch>
Subject: Re: apply chown() to a symlink
Message-Id: <9sjhr3$hr3$1@wsc10.lrz-muenchen.de>
Clinton A. Pierce wrote:
> [Posted and mailed]
>
> In article <9sh9qt$jrn$1@holly.rdwarf.com>,
> Louis Erickson <wwonko@rdwarf.com> writes:
>> Radu Muschevici <grinsefisch@gmx.ch> wrote:
>>: apparently, if perl's chmod() is applied on a symbolic link, it
>>: changes the owner of the file which the link points to.
>>: but how can I change the owner of the symlink itself??
>>
>> Well, chmod changes the access permissions for a file, not the
>> owner.
>> You'd be able to change the owner with chown. See perldoc -f chown
>>
>> Most Unix systems don't have any access permissions for the
>> symbolic
>> link, anyway, so it must change the real file. Symlinks do,
>> however have owners, which can be changed independently.
>>
>> I'm not quite sure which you mean to be changing here, but, if it's
>> the permissions, you can't change those on a symlink, and if it's
>> the owner, then you need to use chown().
I'm sorry, I was was thiniking of chown() but mistakenly wrote
chmod().
> It appears as though this behavior might vary depending on Unix
> systems. The man pages for Linux, for example, indicate that there's
> a chown(2)
> and a lchown(2) system call. At one point the behavior of chown was
> to change the symlink, at another point it time it was to change the
> referent.
>
> Now there's two syscalls so you can pick which behavior you're
> looking for. If you call chown(2) now it changes the referent, and
> lchown(2) changes the link.
>
> Perl, FWIW, seems to go looking for an lchown(2) function and if
> you've
> got it, it's used. So Perl _should_ be changing the link itself.
On my system (Debian Linux (woody), x86, Perl 5.6.1) perl's chown()
always follows the symlink and changes the mode of the file pointed
at.
example 1:
$touch /tmp/file
$ ln -s /tmp/file /tmp/link1
$ perl -e 'print chown(0, 0, "/tmp/link1")'
1
chown() changes the mode of /tmp/file, NOT /tmp/link1
example2:
$ ln -s /nothing /tmp/link2
$ perl -e 'print chown(0, 0, "/tmp/link2")'
0
here chown() follws the symlink which points to a nonexistent file
and fails.
strange enough, POSIX::chown() behaves exactly the same, and there is
no POSIX::lchown() ...
Radu
------------------------------
Date: Sat, 10 Nov 2001 17:50:50 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: apply chown() to a symlink
Message-Id: <9sjpdq$pmb$1@holly.rdwarf.com>
Radu Muschevici <grinsefisch@gmx.ch> wrote:
: Clinton A. Pierce wrote:
:> [Posted and mailed]
:>
:> In article <9sh9qt$jrn$1@holly.rdwarf.com>,
:> Louis Erickson <wwonko@rdwarf.com> writes:
:>> Radu Muschevici <grinsefisch@gmx.ch> wrote:
:>>: apparently, if perl's chmod() is applied on a symbolic link, it
:>>: changes the owner of the file which the link points to.
:>>: but how can I change the owner of the symlink itself??
[ Interesting information which I had slightly wrong snipped. ]
: On my system (Debian Linux (woody), x86, Perl 5.6.1) perl's chown()
: always follows the symlink and changes the mode of the file pointed
: at.
[ Good examples trimmed. ]
: strange enough, POSIX::chown() behaves exactly the same, and there is
: no POSIX::lchown() ...
Yes, now that I get out the tool and fool with it, mine has the same
behavior; it follows the link.
Perhaps someone wiser than I will make a better suggestion, but you
always use /bin/chmod, which does seem to get it right.
Not the world's most efficient solution, I fear.
------------------------------
Date: Sat, 10 Nov 2001 18:01:22 GMT
From: KT <kteegirl24@hotmail.com>
Subject: color coded traceroute
Message-Id: <3BED6A26.9090606@hotmail.com>
Hello,
I wrote a script in modperl so that when you enter in an IP it displays
a traceroute. I want to make it so that it displays the data if the hop
is over 200 to display those results in yellow and if it's over 500 to
display in red. Does anyone have any suggestions on how I could color
code this? I have flipped through all my books adn can't seem to grasp
it (I'm fairly new at this). Here's the code I have so far\;
<& /generalAppC/setupStylesheet.cmp &>
<%$form%>
<TABLE>
<TR><TD class='displaytable'><%$traceroute%></TD></TR>
</TABLE>
<%init>
my $traceroute;
if($ARGS{ip}){
$traceroute = `/usr/sbin/./traceroute -I -m15 $ARGS{ip}`;
$traceroute =~ s/\n/<BR>/g;
}
my $form = qq~
<html>
<title>Traceroute Tool</title>
<body bgcolor="EEEEEE" link=blue alink=blue vlink=blue text=black>
<TR>
<TD>
<FONT SIZE=2><B>Type in an IP or domain name to run a
traceroute</B></FONT></TD></TR>
<FORM ACTION="$ENV{SCRIPT_NAME}" METHOD="POST">
<INPUT TYPE="TEXT" NAME="ip">
<TD class='displaytable'><INPUT TYPE="SUBMIT" NAME="sub" VALUE="submit">
</TD><TR></TABLE></FORM>~;
</%init>
Thank you in advance for any help.
------------------------------
Date: Sat, 10 Nov 2001 20:58:31 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: color coded traceroute
Message-Id: <slrn9ur57h.m1m.efflandt@typhoon.xnet.com>
On Sat, 10 Nov 2001 18:01:22 GMT, KT <kteegirl24@hotmail.com> wrote:
> Hello,
>
> I wrote a script in modperl so that when you enter in an IP it displays
> a traceroute. I want to make it so that it displays the data if the hop
> is over 200 to display those results in yellow and if it's over 500 to
> display in red. Does anyone have any suggestions on how I could color
> code this? I have flipped through all my books adn can't seem to grasp
> it (I'm fairly new at this). Here's the code I have so far\;
This html question has nothing to do with Perl. I am not familiar with
stylesheets, but you could always put good old fashioned <font
color=red>This is red</font> tags around the desired text.
This might be easier if you captured the traceroute output into a list
instead of a scalar. Then you could do a foreach loop and only color code
the line(s) that meet your criteria (easier to parse a line than a page).
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 10 Nov 2001 14:35:30 -0500
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: converting ^M characters to \n
Message-Id: <1f2nl1w.18pi2tu1qhpc7rN%planb@newsreaders.com>
Alan J. Flavell <flavell@mail.cern.ch> wrote:
> On Nov 9, Tad McClellan inscribed on the eternal scroll:
>
> > >> $x =~ tr/\r//d;
> >
> > the tr/// above removes _all_ CRs regardless of the value in $/
>
> On the Mac, as I understand it, it'll remove all linefeeds, and leave
> any CRs alone.
Uhm, did you snip a bit too much above? There was a mention of chomp
which would make your comment make sense...
On the Mac, because of the value in $/, chomp removes 0x0d (LF).
But tr/\r//d will, as Tad said, remove CRs regardless of the value in $/
(which raises the question as to why there isn't the equivalent for
LF's, I know that l and f are both already used for something else, but
what about \N?).
> If it's \015 you're aiming to remove, wouldn't it be better to say so
> directly?
Are you confusing CRs and LFs here?
--
JBM
"Your depression will be added to my own" -- Marvin of Borg
------------------------------
Date: Sat, 10 Nov 2001 21:54:16 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: converting ^M characters to \n
Message-Id: <Pine.LNX.4.30.0111102054290.16744-100000@lxplus023.cern.ch>
On Nov 10, J.B. Moreno inscribed on the eternal scroll:
> Alan J. Flavell <flavell@mail.cern.ch> wrote:
>
> > On Nov 9, Tad McClellan inscribed on the eternal scroll:
> >
> > > >> $x =~ tr/\r//d;
> > >
> > > the tr/// above removes _all_ CRs regardless of the value in $/
> >
> > On the Mac, as I understand it, it'll remove all linefeeds, and leave
> > any CRs alone.
>
> Uhm, did you snip a bit too much above?
Well, I was commenting on what I quoted, and not on what I snipped.
You're referring to this part, right? -
|>This is more for my education than the original poster's, but
|>couldn't one accomplish the same thing by the use of chomp()?
|
|No.
|
|chomp() will remove only a CR at the end of $x, and only if
|
| $/ = "\r";
However, this again (mis)identifies the actual control character
whose value is CR (x0D or \015), with the logical \r. As perldoc
perlport explains, these are not the same thing on all platforms.
> On the Mac, because of the value in $/, chomp removes 0x0d
Yes
> (LF).
Pardon?
> But tr/\r//d will, as Tad said, remove CRs regardless of the value in $/
No, it'll remove occurrences of \r, whatever they may be on the
specific platform. I was under the impression that the previous
discussion had not _meant_ to be platform-specific, but had
inadvertently become so: I was trying to correct that by pointing to
the specific example of the Mac.
Ref: http://www.perldoc.com/perl5.6/pod/perlport.html#Newlines
> (which raises the question as to why there isn't the equivalent for
> LF's, I know that l and f are both already used for something else, but
> what about \N?).
Sorry, I don't follow you there.
> > If it's \015 you're aiming to remove, wouldn't it be better to say so
> > directly?
>
> Are you confusing CRs and LFs here?
Am I?
best regards.
------------------------------
Date: 10 Nov 2001 09:47:32 -0800
From: james@ryley.com (james)
Subject: help - using regular expressions with conditional while
Message-Id: <79fd9c90.0111100947.75c7e826@posting.google.com>
No answer on this is comp.lang.perl, so maybe someone here can help:
Anyone know how to make the PERL substitute function work as I
intended below? I am trying to parse HTML. The removal of extra
whitespace is of great help, as it simplifies pattern matching. But,
removing whitespace messes up the formatting of things in <PRE> tags,
so I wanted to make the substitute function skip text enclosed in
<PRE> tags. The code below ignores the conditional and replaces
between <PRE> tags also. FYI, $content stores an HTML page.
Thanks,
James
== CODE SNIPPET (that does not work) ============================
while ($content !~ /<PRE>.+?<\/PRE>/i) {
$content =~ s/ {2,}/ /g; # multiple spaces to one
$content =~ s/[\n\t\f]//g; # remove newline, formfeed, tab
}
------------------------------
Date: Sat, 10 Nov 2001 18:04:51 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: help - using regular expressions with conditional while
Message-Id: <mbudash-2597D3.10045210112001@news.sonic.net>
In article <79fd9c90.0111100947.75c7e826@posting.google.com>,
james@ryley.com (james) wrote:
> No answer on this is comp.lang.perl, so maybe someone here can help:
>
> Anyone know how to make the PERL substitute function work as I
> intended below? I am trying to parse HTML. The removal of extra
> whitespace is of great help, as it simplifies pattern matching. But,
> removing whitespace messes up the formatting of things in <PRE> tags,
> so I wanted to make the substitute function skip text enclosed in
> <PRE> tags. The code below ignores the conditional and replaces
> between <PRE> tags also. FYI, $content stores an HTML page.
>
> Thanks,
> James
>
> == CODE SNIPPET (that does not work) ============================
>
> while ($content !~ /<PRE>.+?<\/PRE>/i) {
>
> $content =~ s/ {2,}/ /g; # multiple spaces to one
> $content =~ s/[\n\t\f]//g; # remove newline, formfeed, tab
> }
as has been said 'round here many many times, regexes are generally a
poor solution for parsing html, but if this works for you in your
specific purpose, good...
a dot in a match expression will not match newlines unless the 's' flag
is used, so if there are newlines between the <pre> tags, the expression
will not match.
additionally, i suggest using a different set of match delimiters to
avoid "leaning toothpick scenario".
so, try:
while ( $content !~ m{<PRE>.+?</PRE>}is ) {
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sat, 10 Nov 2001 18:27:03 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: help - using regular expressions with conditional while
Message-Id: <slrn9uqpq1.r6u.tadmc@tadmc26.august.net>
james <james@ryley.com> wrote:
>No answer on this is comp.lang.perl, so maybe someone here can help:
That is probably because that newsgroup does not exist.
It was rmgrouped many *years* ago. There are poorly configured
news servers that make it appear as if it exists when it does not.
Complain to your news administrator for sending you on a
wild goose chase.
>Anyone know how to make the PERL
It is spelled "Perl" or "perl", not PERL.
There is a Perl FAQ about that:
What's the difference between "perl" and "Perl"?
>substitute function work as I
>intended below? I am trying to parse HTML.
You should use a module that understands HTML to process HTML.
There is a Perl FAQ about that too:
perldoc -q HTML
"How do I remove HTML from a string?"
Which gives several examples of tricky, yet legal, HTML that may bite you.
>The removal of extra
>whitespace is of great help, as it simplifies pattern matching. But,
>removing whitespace messes up the formatting of things in <PRE> tags,
>so I wanted to make the substitute function skip text enclosed in
><PRE> tags. The code below ignores the conditional
^^^^^^^^^^^^^^^^^^^^^^^
No it doesn't.
>and replaces
>between <PRE> tags also. FYI, $content stores an HTML page.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>while ($content !~ /<PRE>.+?<\/PRE>/i) {
$content has an entire "page" it in it. If you have a <pre>
start and end tag in the page (and on the same "line"), then
the conditional is true.
If you want to match when the start/end tags are on different
lines, then you need to allow for matching newlines:
/<PRE>.+?<\/PRE>/is
> $content =~ s/ {2,}/ /g; # multiple spaces to one
You can use tr to squeeze characters: tr/ / /s;
$content is the whole page, not just the part between pre tags,
so the s/// is applied to all of the page.
> $content =~ s/[\n\t\f]//g; # remove newline, formfeed, tab
You can use tr to delete characters: tr/\n\t\f//d;
>}
and since you say the spaces _are_ going away, then the conditional
was not ignored. It evaluated to "true" and evaluated its block,
just like it is supposed to.
Here is some legal HTML to consider:
-------------------------
<pre
>
here is some preformated text. Don't be squeezing
spaces in here.
</pre >
-------------------------
What should your program do if you add a line before that
<!--
and after that
-->
??
Then it would "look like" a <pre> element when it is not a <pre> element.
If you had provided some sample data, I would have given code
to do what you wanted done. But it would not work on arbitrary
HTML, only on a severely restricted subset of HTML.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Nov 2001 15:31:28 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: help with hashref
Message-Id: <9sjh8g$13db9v$2@fu-berlin.de>
Jens Luedicke <jens@irs-net.com> wrote:
> David K. Wall wrote:
>> It's far to late at night (as I write this) for me to make coherent
>> comments on code; however, you may find this URL interesting:
>> http://www.jwz.org/doc/threading.html
> When I try to analyze the structure of my hashref with Data::Dumper
> I find lots of buggy and wrong elements. Because my code should create the
> hashref much different than Data::Dumper lists it and it works different.
> Is Data::Dumper reliable?
well, it is reliable in the way that it works correctly if you
eval the result, like it was said by somebody else. maybe
you want to have a look at Data::Denter.
hth, tina
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Sat, 10 Nov 2001 16:42:38 +0100
From: Jens Luedicke <jens@irs-net.com>
Subject: Re: help with hashref
Message-Id: <9sji2l$gs4$00$1@news.t-online.com>
Tina Mueller wrote:
> well, it is reliable in the way that it works correctly if you
> eval the result, like it was said by somebody else. maybe
> you want to have a look at Data::Denter.
thanks.
--
Jens Luedicke
jens@irs-net.com
------------------------------
Date: Sat, 10 Nov 2001 16:20:48 -0500
From: "Alex Shi" <chpshi@stonix.com>
Subject: History Event
Message-Id: <kTgH7.1884$NE2.13344@news.eol.ca>
Hello,
I'm trying to identify a history event: do you think Matt is the first one
who
created Web based BBS using Perl? If not, who is the first one? If any
one here happen to know about this topic please help. Thanks!
Regards,
Alex
------------------------------
Date: Sat, 10 Nov 2001 16:33:52 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: how to print out every second value of an array
Message-Id: <Xns9155A8819AA82Laocooneudoramailcom@62.153.159.134>
Uri Guttman <uri@stemsystems.com> wrote in
news:x7eln7qjgn.fsf@home.sysarch.com:
>
> comp.lang.perl is a dead group no matter what your server says.
>
>>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>
> L> example :
> L> my $c = 0;
> L> while($i <= $#data) {
> L> $joined[$c++] = $data[$i++] . $data [$i++];
>
> have you tried this? the sequencing of side effects like ++ are a known
> issue in perl. the order and when they get executed are not well (if at
> all) defined. even c has no proper definition if you do multiple ++ on
> the same variable in one statement. it is much safer to use $i and $i +
> 1 and then do $i += 2.
I remember i tried it and it worked.
> uri
Lao
------------------------------
Date: Sat, 10 Nov 2001 17:57:55 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how to print out every second value of an array
Message-Id: <slrn9uqnh2.r56.tadmc@tadmc26.august.net>
Laocoon <Laocoon@eudoramail.com> wrote:
>Uri Guttman <uri@stemsystems.com> wrote in
>news:x7eln7qjgn.fsf@home.sysarch.com:
>>>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>>
>> L> example :
>> L> my $c = 0;
>> L> while($i <= $#data) {
>> L> $joined[$c++] = $data[$i++] . $data [$i++];
>>
>> have you tried this? the sequencing of side effects like ++ are a known
>> issue in perl. the order and when they get executed are not well (if at
^^^^^ ^^^^^^^^ ^^^
>> all) defined.
^^^^^^^
>I remember i tried it and it worked.
I realize that you were responding to Uri's question, but it
kind of looks like you missed Uri's point.
Since the order of evaluation (which is what Uri meant rather
than executed) is not defined, the implementors of perl are
free to change it whenever they want.
In other words, "it worked today" does not imply that it will
work tomorrow. The next version of Perl might do things in
a different order.
You could upgrade your perl and your program would break.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Nov 2001 20:40:26 +0100
From: "Bob Rock" <no_spam.yet_another_apprentice@hotmail.com>
Subject: How to query or discover a script's filename???
Message-Id: <9sk08n$13il2u$1@ID-98646.news.dfncis.de>
Hello,
how can a Perl script query or discover its own filename?
Thank you.
Regards,
Bob Rock
------------------------------
Date: Sat, 10 Nov 2001 20:58:39 +0100
From: Jens Luedicke <jens@irs-net.com>
Subject: Re: How to query or discover a script's filename???
Message-Id: <9sk12n$bfh$00$1@news.t-online.com>
Bob Rock wrote:
> how can a Perl script query or discover its own filename?
try: $0
--
Jens Luedicke
jens@irs-net.com
------------------------------
Date: Sat, 10 Nov 2001 21:08:30 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to query or discover a script's filename???
Message-Id: <slrn9ur5qd.m1m.efflandt@typhoon.xnet.com>
On Sat, 10 Nov 2001, Bob Rock <no_spam.yet_another_apprentice@hotmail.com>
wrote:
>
> how can a Perl script query or discover its own filename?
> Thank you.
$0 contains the path_if_any/name the script was called as, but this is not
necessarily the real name of the script, it could be a symlink. But that
can be used to advantage by having the script parse $0 and perform
different functions from the same script depending upon its name.
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 10 Nov 2001 22:32:14 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: How to query or discover a script's filename???
Message-Id: <9sk9te$3kr0n1@news1s.iddeo2.es>
On Sat, 10 Nov 2001 20:40:26 +0100, Bob Rock <no_spam.yet_another_apprentice@hotmail.com> wrote:
: how can a Perl script query or discover its own filename?
perldoc FindBin
-- fxn
------------------------------
Date: Sat, 10 Nov 2001 22:59:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: md5 and hashrefs
Message-Id: <07crutghvonie9c0t3p895q09kah3o4705@4ax.com>
Jens Luedicke wrote:
>Sometimes those Message-ID's and In-Reply-To's vary in their
>length, so would it make sense to create md5 digests to 'waste'
>the same amout of space to identify each node?
>
>Or is this idea too strange to be useful at all? ;-)
The sillyness of the idea hides in the fact that the string -> md5
mapping is not unique. Even though the chance of a collision is very
small, it is not unthinkable. After all, md5 only produces a 16 byte
string from whatever string you feed it.
--
Bart.
------------------------------
Date: Sat, 10 Nov 2001 22:31:32 GMT
From: jeff <none@nothere.please.net>
Subject: module to help change login shell (no..chsh is not available on solaris...)
Message-Id: <kdarutggbmbko8btss4ajugeqbh25jotij@4ax.com>
I hope this is the right forum for a question such as this. I search
usenet as much as I could..and google has been down for a while, so I
cant search the archives..
Solaris does not have chsh functionality any longer (bastards..)
so, i am trying to write a setuid (*GASP*) script to enable users to
change their passwords and gecos info without bothering me anymore!!
(alternatives to this are VERY welcomed..tried sun's binary
compatability mode..doesnt work, and recompiling the source to the
older bsd chsh source was just a horrible idea waiting to happen..)
I'd rather not rewrite the whole /etc/passwd file each time manually
using "open" and such..thats just waiting to crash the system.
Ok, i think you can see where Im going with this (or rather, where Ive
been delegated to do the task).
ANY help appreciated!!
jeff
------------------------------
Date: Sat, 10 Nov 2001 15:28:08 GMT
From: "Daniel Berger" <djberg96@hotmail.com>
Subject: Re: Perl vs. Active Perl
Message-Id: <cIbH7.2623$T6.111836@typhoon.mn.mediaone.net>
"Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
news:slrn9upvss.scl.tim@vegeta.ath.cx...
<snip>
> You are correct. Regardless of what I quoted from that very same page,
> IndigoPerl's license is only _slightly_ less restictive than
> ActivePerl's. (ActivePerl requires written permission for
> commercial redistribution whether you make less the $1_000/yr or not.)
>
> You can always get yourself a linux distro and compile perl yourself...
>
> Or bend over backwards, compile it for Win32 yourself...
>
<snip>
There *used* to be PerlMagic for Win32, which was basically a free distro
for Win32. These were the same folks that made the CodeMagic IDE. However,
after just checking codemagiccd.com, it looks like they're defunct. That's
too bad because that IDE really had potential (it sure was a helluva lot
better than Komodo).
For a scathing commentary on ActiveState Perl (and its licensing), see
www.petes-place.com.
Regards,
Mr. Sunblade
------------------------------
Date: Sat, 10 Nov 2001 21:14:24 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: Perl vs. Active Perl
Message-Id: <slrn9ur6k2.chf.tim@vegeta.ath.cx>
Daniel Berger <djberg96@hotmail.com> graced us by uttering:
[ snip ]
> There *used* to be PerlMagic for Win32, which was basically a free distro
> for Win32. These were the same folks that made the CodeMagic IDE. However,
> after just checking codemagiccd.com, it looks like they're defunct. That's
> too bad because that IDE really had potential (it sure was a helluva lot
> better than Komodo).
I remember CodeMagic, but never used it. I mostly use HomeSite and
UltraEdit-32 when I was restricted to Win32 (before I found my
cygwin/vim environment ;).
> For a scathing commentary on ActiveState Perl (and its licensing), see
> http://www.petes-place.com .
Thank God. I've been flamed off the face of the usenet for saying
things not remotely touching those; and from a former ActiveDroid, no
less!
> Regards,
> Mr. Sunblade
thx,
Tim Hammerquist
--
/earth is 98% full ... please delete anyone you can.
------------------------------
Date: Sat, 10 Nov 2001 13:04:44 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Perl/DBI update q
Message-Id: <EMfH7.130$Nb2.302892@news.uswest.net>
Hi folks!
I am writing a site which has an admin page where data can be added,
removed & updated in a database via DBI. I have the add & remove working now
(many thanks to you fine folks!!!) and on the update section, I can update a
row if only 1 field is specified; if more than 1 is specified the entire
update fails. I have checked Programming the Perl DBI, the man pages, the
perldoc pages & I am baffled. I am guessing is it a problem with quoting or
SQL statement formation. Below is the code & the SQL generated by it.
Many many thanks in advance!!!
Michael
--
== CigarPool ==
http://www.cigarpool.com
~~~~~~~~~~~~~~~~~~~~~~~~
$dbpath = './db';
$db = 'pipes';
$dbh =
DBI->connect("DBI:CSV:f_dir=$dbpath;csv_sep_char=:",,,{RaiseError=>1});
$STATEMENT = sprintf "UPDATE $db
SET %s = '%s'
WHERE PRODUCTNUMBER = '$modproductnumber'",
join(", ",@fields), join(", ",@values);
#-->
# Debug
print "<BR>var=|$STATEMENT|\n";
#-->
$dbh->do( $STATEMENT );
+++++++
when 1 item is selected to update:
var=|UPDATE pipes SET BRAND = 'ee' WHERE PRODUCTNUMBER = 'e1007'| - succeeds
when 2 items are selected to update:
var=|UPDATE pipes SET BRAND, MODEL = 'ee, ee' WHERE PRODUCTNUMBER =
'e1007'| - fails
~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Sat, 10 Nov 2001 21:10:10 GMT
From: sconfusion1@home.com (Steven Edwards)
Subject: Re: Perl/DBI update q
Message-Id: <3bee952c.22765762@news>
On Sat, 10 Nov 2001 13:04:44 -0700, "Michael Cook"
<mikecook@cigarpool.com> wrote:
>Hi folks!
> I am writing a site which has an admin page where data can be added,
>removed & updated in a database via DBI. I have the add & remove working now
>(many thanks to you fine folks!!!) and on the update section, I can update a
>row if only 1 field is specified; if more than 1 is specified the entire
>update fails. I have checked Programming the Perl DBI, the man pages, the
>perldoc pages & I am baffled. I am guessing is it a problem with quoting or
>SQL statement formation. Below is the code & the SQL generated by it.
> Many many thanks in advance!!!
> Michael
>
>== CigarPool ==
>http://www.cigarpool.com
I don't think you can use sprintf to format an sql statement like
that. The proper SQL should be:
SET BRAND = 'ee', MODEL = 'ee' WHERE PRODUCTNUMBER = 'e1007'
Try this; a workaround using sprintf:
$set = '';
while (@fields) {
$set .= sprintf "%s = '%s'", pop(@fields), pop(@values);
}
$STATEMENT = "UPDATE $db SET $set WHERE PRODUCTNUMBER =
'$modproductnumber'";
That should get you a proper SQL statement. :-)
-Steven
------------------------------
Date: Sat, 10 Nov 2001 14:49:06 GMT
From: sconfusion1@home.com (Steven Edwards)
Subject: Re: regular expresion
Message-Id: <3bf03ef3.689360@news>
On Sat, 10 Nov 2001 04:10:25 GMT, in comp.lang.perl.misc you wrote:
>Rand al'Thor <sconfusion1@home.com> wrote:
>
>>$t =~ s/^.*\"([^\"]+)\".*/$1/;
> ^ ^ ^
> ^ ^ ^
>
>None of those backslashes serve any purpose. So why are they there?
The backslashes escape the " marks. It always works for me. Can you
give another version?
-Steven
------------------------------
Date: Sat, 10 Nov 2001 15:19:34 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regular expresion
Message-Id: <slrn9uqe7t.qrb.tadmc@tadmc26.august.net>
[ Please DO NOT send stealth Cc's. It annoys people. Thank you. ]
Steven Edwards <sconfusion1@home.com> wrote:
>On Sat, 10 Nov 2001 04:10:25 GMT, in comp.lang.perl.misc you wrote:
>>Rand al'Thor <sconfusion1@home.com> wrote:
>>
>>>$t =~ s/^.*\"([^\"]+)\".*/$1/;
>> ^ ^ ^
>> ^ ^ ^
>>
>>None of those backslashes serve any purpose. So why are they there?
>
>The backslashes escape the " marks. It always works for me.
The quotes are not "special". They do not need any escaping!
>Can you
>give another version?
Uhh, yes:
$t =~ s/^.*"([^"]+)".*/$1/;
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Nov 2001 16:11:22 GMT
From: sconfusion1@home.com (Steven Edwards)
Subject: Re: regular expresion
Message-Id: <3bed5088.5191347@news>
On Sat, 10 Nov 2001 15:19:34 GMT, tadmc@augustmail.com (Tad McClellan)
wrote:
>
>[ Please DO NOT send stealth Cc's. It annoys people. Thank you. ]
It wasn't a Bcc; I hit the wrong button to reply and sent an email
reply by accident.
>The quotes are not "special". They do not need any escaping!
>
>
>>Can you
>>give another version?
>
>
>Uhh, yes:
>
> $t =~ s/^.*"([^"]+)".*/$1/;
>
>:-)
I wasn't trying to be a smartass -- it was a serious question. I was
not aware that quotes did not need to be escaped. I assumed that
since they needed to be escaped in strings:
$t = "Hello \"World\"";
that they also needed escaping in regular expressions. Thanks for
letting me know that. :-)
-Steven
------------------------------
Date: Sat, 10 Nov 2001 06:34:06 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regular Expressions
Message-Id: <3bed3ae2$1@news.microsoft.com>
"Anya Miretsky" <anyam_99@yahoo.com> wrote in message
news:1e0c6f7a.0111090745.385e55b@posting.google.com...
> I am new to Perl, so therefore the simple question..
>
> How do I use a regular expression to make all uppercase letters in a
> string into lowercase?
You don't.
The best way is to use the "lc" function, details see "perldoc -f lc".
> I've tried $x =~ s/[A-Z]/[a-z]/g; and this doesn't work.
You cannot use a character range on the right side (the right side of a "s"
is NOT a regular expression). Maybe you meant
tr /A-Z/a-z/;
but this would fail for all letters which are not in the 7 bit ASCII range
of A-Z.
jue
------------------------------
Date: Sat, 10 Nov 2001 06:36:02 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regular Expressions
Message-Id: <3bed3b55$1@news.microsoft.com>
"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn9ununl.cof.rgarciasuarez@rafael.kazibao.net...
> Anya Miretsky wrote in comp.lang.perl.misc:
> > How do I use a regular expression to make all uppercase letters in a
> > string into lowercase?
> > I've tried $x =~ s/[A-Z]/[a-z]/g; and this doesn't work.
>
> That would be tr/// instead of s///g (and without the brackets).
> Look up tr/// in perlop.
Which of course fails for all letters outside of 7-bit ASCII [A-Z].
jue
------------------------------
Date: Sat, 10 Nov 2001 14:13:55 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: system() and exec()
Message-Id: <slrn9uqasl.qen.tadmc@tadmc26.august.net>
Alice Wonder <alicewonder2321212USA@yahoo.com> wrote:
>I read about the two functions at www.perl.com but don't really understand
>how to use them.
You can read about them from your very own hard drive too you know:
perldoc -f system
perldoc -f exec
>Let's say I have a myC++.exe and run it at the command prompt (Windows
>2000) with:
>
>c:\> myC++ employee 123
>
>How do I embed the common in Perl so that I could execute the C++ program in
>Perl?
system 'myC++ employee 123'; # did you even try this first?
Or if you want to know if the command had a problem running,
check the return value:
system 'myC++ employee 123' and die "problem running myC++";
or
!system 'myC++ employee 123' or die "problem running myC++";
>Or am I looking at the wrong functions to use? Please kindly advise.
You may be looking at the wrong function, but we can't be sure.
If you want to run the program, you are looking at the right
function (system).
If you do not understand the Unix process model, then exec()
is just likely to confuse you.
If you want to run the program and capture the program's output
into your Perl program, then you are looking at the wrong function.
(but "perldoc -f system" will tell you what the Right Tool is for
that job)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Nov 2001 16:06:38 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: system() and exec()
Message-Id: <9sjjae$3l2br2@news1s.iddeo2.es>
On Sat, 10 Nov 2001 07:47:34 -0500, Alice Wonder <alicewonder2321212USA@yahoo.com> wrote:
: I read about the two functions at www.perl.com but don't really understand
: how to use them.
:
: Let's say I have a myC++.exe and run it at the command prompt (Windows
: 2000) with:
:
: c:\> myC++ employee 123
:
: How do I embed the common in Perl so that I could execute the C++ program in
: Perl? Or am I looking at the wrong functions to use? Please kindly advise.
Basically,
system "myC++ employee 123";
// (1)
executes "myC++" with the given parameters and the Perl program
follows at (1) once system() returns, whereas
exec "myC++ employee 123";
// (1)
replaces the current running Perl program with "myC++" so that we
never get at (1). That is, exec() never returns.
Read perldoc -f system and perldoc -f exec for further details.
-- fxn
------------------------------
Date: Sat, 10 Nov 2001 14:13:53 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: which is faster? =1 or ++
Message-Id: <slrn9uqail.qen.tadmc@tadmc26.august.net>
Iain Chalmers <bigiain@mightymedia.com.au> wrote:
>Luckily, it looks like the assign way is quicker anyway, so theres no
>reason to use the increment version. (I seem to remember a rant from
>someone, perhaps Randal, about the evils of "cargo cult programming"
>propagating memes like $|++ as being "the right way to do it"...)
I think it was someone ranting _against_ Randal.
I think Randal eventually said he should probably not
be showing folks the $|++ way.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 2108
***************************************