[16066] in Perl-Users-Digest
Perl-Users Digest, Issue: 3478 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 26 03:05:55 2000
Date: Mon, 26 Jun 2000 00:05:13 -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: <962003112-v9-i3478@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Jun 2000 Volume: 9 Number: 3478
Today's topics:
"Kill" function doesn't work. <wgshi@cs.ualberta.ca>
Re: "Kill" function doesn't work. (Clinton A. Pierce)
Re: "Kill" function doesn't work. <jjchew@math.utoronto.ca>
attach file in e-mail <ltlau@yahoo.com>
Re: Can mod_perl pooled db connections be attached to h (brian d foy)
Re: Creating a cause from information. <smerr612@startrekmail.com>
dbi oracle Select example <taylorr@greendot.net>
Re: Dereferencing a two dimensional array? <shanen@my-deja.com>
Re: Get the matched position in regexp <uri@sysarch.com>
Re: Get the matched position in regexp <godzilla@stomp.stomp.tokyo>
Re: matching question (http related) <email@address.com>
Re: matching question (http related) <godzilla@stomp.stomp.tokyo>
Re: matching question (http related) <godzilla@stomp.stomp.tokyo>
Re: matching question (http related) (Keith Calvert Ivey)
Re: matching question (http related) <tina@streetmail.com>
Re: matching question (http related) <godzilla@stomp.stomp.tokyo>
Re: matching question (http related) <email@address.com>
Re: matching question (http related) <email@address.com>
Re: matching question (http related) <email@address.com>
Re: matching question (http related) <godzilla@stomp.stomp.tokyo>
Re: matching question (http related) (Michael Budash)
Re: NT vs Unix detection <lwaibel@cwia.com>
Re: NT vs Unix detection <email@address.com>
Re: NT vs Unix detection <email@address.com>
on again/off again CGI prob... <stew777@email.msn.com>
Re: on again/off again CGI prob... <news@raincloud-studios.com>
Re: Regex replacing bits & pieces of a string in one sh <egberts@mac.com>
Re: Stupid Perl 'if' Question <juex@deja.com>
Re: test for membership in an array? <PostNoEmail <i_am_not@erols.com>>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Jun 2000 20:21:31 -0600
From: Weiguang Shi <wgshi@cs.ualberta.ca>
Subject: "Kill" function doesn't work.
Message-Id: <Pine.SOL.3.96.1000625201703.27279A-100000@stauffer.cs.ualberta.ca>
Hi, there:
I wrote the one-line script to kill all the processes with 4404<pid<4900
below:
$ ps -u wgshi|perl -ne 'chop(); @a=split / /;if($a[1]<4900 && $a[1]>4404)
{kill 9, $a[1], "\n";} '
Killed
And got the answer "Killed" as shown above. However, none of the processes
was actually killed. Why this happened?
Thanks very much.
Weiguang
------------------------------
Date: Mon, 26 Jun 2000 04:32:11 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: "Kill" function doesn't work.
Message-Id: <f1B55.11140$fR2.129987@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <Pine.SOL.3.96.1000625201703.27279A-100000@stauffer.cs.ualberta.ca>,
Weiguang Shi <wgshi@cs.ualberta.ca> writes:
> Hi, there:
>
> I wrote the one-line script to kill all the processes with 4404<pid<4900
> below:
>
> $ ps -u wgshi|perl -ne 'chop(); @a=split / /;if($a[1]<4900 && $a[1]>4404)
> {kill 9, $a[1], "\n";} '
> Killed
>
> And got the answer "Killed" as shown above. However, none of the processes
> was actually killed. Why this happened?
OUCH. I have no idea what the heck you were trying to accomplish...but
there's a few things you should be aware of:
First, kill has a return value. It returns the number of processes that
were signaled. So, what you really want is:
kill 15, $a[1] or warn "Cannot kill pid $a[1]: $!";
Secondly, killing with a signal 9 is not a particularly good idea. It
doesn't let processes clean up after themselves--you'll regret it eventually.
Lastly...kill takes a list. The statement:
kill 9, $a[1], "\n";
Kills the process whose PID is in $a[1] and the process who's pid is "\n".
What process is that? Dunno. 0? 1? 15? I'd have to see what perl is
looking for there. But unquestionably, it's not what you want.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 26 Jun 2000 01:53:44 -0400
From: John J Chew <jjchew@math.utoronto.ca>
Subject: Re: "Kill" function doesn't work.
Message-Id: <B57C6828.4702%jjchew@math.utoronto.ca>
In article f1B55.11140$fR2.129987@news1.rdc1.mi.home.com, Clinton A. Pierce
> In article
> <Pine.SOL.3.96.1000625201703.27279A-100000@stauffer.cs.ualberta.ca>,
> Weiguang Shi <wgshi@cs.ualberta.ca> writes:
>> Hi, there:
>>
>> I wrote the one-line script to kill all the processes with 4404<pid<4900
>> below:
>>
>> $ ps -u wgshi|perl -ne 'chop(); @a=split / /;if($a[1]<4900 && $a[1]>4404)
>> {kill 9, $a[1], "\n";} '
>> Killed
>>
>> And got the answer "Killed" as shown above. However, none of the processes
>> was actually killed. Why this happened?
Not strictly speaking a Perl problem, but the 'Killed' shell message
indicates that the job that was running (ps|perl) terminated when it
was killed. Unless you or someone else killed it from another session,
it probably killed itself.
If you don't want it to do this, you should probably check the pid
being killed against the value of $$.
John
--
John J. Chew, III
jjchew@math.utoronto.ca * http://www.math.utoronto.ca/jjchew
------------------------------
Date: Mon, 26 Jun 2000 10:02:42 +0800
From: "JL" <ltlau@yahoo.com>
Subject: attach file in e-mail
Message-Id: <3956b9e7@news02.imsbiz.com>
Hi,
Can anyone tell me how to use perl to attach file like using e-mail in
yahoo/hotmail?
Thanks alot.
------------------------------
Date: Mon, 26 Jun 2000 00:18:27 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Can mod_perl pooled db connections be attached to http session?
Message-Id: <brian-2606000018280001@212.sanjose-11-12rs16rt.ca.dial-access.att.net>
In article <8j2m46$36$1@nnrp1.deja.com>, kwiateks@juno.com wrote:
>Does anyone have resources for perl code that will pool db
>(oracle) connections and allow me to attach the connection handle to one
>(and only one) http user session?
i suppose that you could hack Apache::DBI to do such a thing, but
why would you want to?
--
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ
<URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 26 Jun 2000 06:02:36 GMT
From: "Steven Merritt" <smerr612@startrekmail.com>
Subject: Re: Creating a cause from information.
Message-Id: <0mC55.4568$oW3.392850@news.flash.net>
"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn8l8ccd.tq.tadmc@maxim.metronet.com...
> On Fri, 23 Jun 2000 16:07:08 GMT, Steven Merritt
> <smerr612@mailandnews.com> wrote:
>
> >The problem is that you're using the magical angle brackets <> on your
> >filehandle as the only condition of a while loop. These read a line
> >from the filehandle every iteration of the while loop(and only when you
> >use it in a while loop) and put it into $_. So what you've done is
> >basically do two reads, an implicit read, and an explicit read, per
> ^^^^^^^^ ^^^^^^^^
>
> No, both reads were explicit.
>
> One input operator in the while clause, and one input operator
> in the body of the loop.
>
> The _assignment_ is implicit for the while clause one.
True, sorry about that. In my mind the two are pretty much intrinsically
linked. I don't think I've ever done a read without some type of
assignment. After all, what's the point of getting data if you're not going
to put it anywhere, now wether or not you actually _do_ something with it is
up to you.
s/read/"read and assign"/ # for accuracy's sake
Steven
------------------------------
Date: Sun, 25 Jun 2000 18:58:23 -0700
From: Robert <taylorr@greendot.net>
Subject: dbi oracle Select example
Message-Id: <3956B8BF.77770EC8@greendot.net>
Does anyone have a simple dbi based Oracle select query example? I
would just like to see how you execute a select statement on an oracle
db.
Thanks
Robert
------------------------------
Date: Mon, 26 Jun 2000 04:57:42 GMT
From: Shannon Jacobs <shanen@my-deja.com>
To: shanen@acm.org
Subject: Re: Dereferencing a two dimensional array?
Message-Id: <8j6ns1$kvm$1@nnrp1.deja.com>
In article <395361C9.AC8983E7@home.com>,
Michael Carman <mjcarman@home.com> wrote:
> Posted and courtesy copy sent.
>
> Shannon Jacobs wrote:
> >
> > Well, I've seen the kind of stuff that goes here, so I know I'll get
> > flamed for the clueless newbie question
>
> Have you tried the docs? If not, then you probably deserve any
> flaming, especially since you've implied having lurked long enough to
> know better. But if you did, and you're still stumped, then post away.
Thanks, Mr. Carman, but no ice cream for mean Mr. McClellan, even if he
is from my natal state. The ice cream would have involved explaining
what I'm doing in more detail so someone could have guided me down the
Perlish path to Tao--the way that doesn't use so many arrays. As it is,
I'm going to let the churlish code stand, at least for now.
<snip>
> > @jr <= $re[$i];
Whoops. <= was a leftover mistake from one of my many strained efforts
over the hour or two that I wrestled with the problem as the weekend
rushed upon me. = was the correct operator.
<snip>
> Taking a WAG (Wild Ass Guess) from you subject, you appear to be after
> this:
>
> @{$re[$i]}
Very good guess, though the problem was also related to the confusion
between $reslist and $results, which were supposed to be, but obviously
weren't similar references to the same data. I'm still trying to figure
that out, but the code works. I had actually tried @{} fairly early in
the process, but obviously on the wrong thing--it always returned nil.
> Which will deref $re[$i] and give you an array. That still leaves me
> wondering what you're trying to do with the "@a <= @b" construct. What
> it *will* do is compare lengths.
Mea culpa as above. I was actually trying to rush to yet another futile
Japanese lesson... But this mostly reminds me of APL's similar
proclivity to try really hard to do something meaningful, even with
silly typos.
<snip>
> > I have tried many variations. I have been all over the camel book,
> > the docs, FAQs, and various parts of the newsgroups and Internet
> > and cannot figure out how to pass the correct value to $jr.
>
> Thank you for trying. Did you try 'perldoc perlref'? :)
Nope, don't recall trying that one, though I am using -w and -c and
weirdly trapping STDERR most of the time. In fact, just now trying
perlman reveals that "In string, @sys now must be written as \@sys
at /usr/local/bin/perldoc line7, near "/.../yamato.ibm.com/fs/@sys".
Yes, it seems that perldoc is not installed properly on either of the
UNIX boxes... Finally found it buried in the Active Perl documentation
on a Windows 95 box. Not directly referenced in the camel book, but
knowing what I was now looking for and using the camel's page xiv
hint, "man perlref" works on the UNIX boxes, even though perlman
doesn't.
Actually, there is an embarrassment of riches as far as documentation
goes. So far most of it flies over or under my head.
> BTW, $jr is not the same as @jr. In fact, they are completely
> independant. $jr is a scalar, @jr is an array, %jr is a hash. Perl can
> keep them sorted out, and know when you want the scalar and when you
> want an array or hash element (or slice, etc.). You may have a little
> more difficulty, and for that reason it is generally advised to *not*
> use the same name for a scalar/array/hash.
Hmm... I think this is near the philosophical nub. I prefer to work at
the highest level of abstraction that still provides the degree of
control required. Perl doesn't seem to care about levels, and is
perfectly happy to do something at some level or other. In this case it
certainly didn't know which one I wanted--but neither did I.
My current feeling about Perl is that I'm using a trench mortar to kill
flies. Direct pointing didn't work so well, so now I load it and lure
the fly to a bit of apple suspended over the mouth. BABOOM!!! No more
fly. I think. Well, if I didn't get him, at least he's running scared
now.
I'm pretty sure that PHP or ColdFusion might be more appropriate tools
for my lowly flyswatting, but sometimes you have to love the tool
you're with.
> *shrug* Is it a typo? If so 'use strict' will help you catch things
> like that. See 'perldoc strict'
Or "man strict" in this strange mindscape. This is another Perl of
great price that is cast before the swine. I've been through that
section several times and still can't figure out if it will help. I
have also experimented with it, and I can say that it didn't *seem* to
be helpful, but the explanation is still fluttering about overhead.
But thanks again.
--
Spamnuts--not just for breakfast anymore. Be sure to crack the shells
before adding soy sauce.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 26 Jun 2000 02:16:44 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Get the matched position in regexp
Message-Id: <x7wvjdtcdx.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> multiplexor wrote:
>> Is it possible to get the position of the matched part in a string?
>> For example:
>> $_ = 'ABCDE'; if (/C/) { print "C is at the 3rd character". }
>> How do I get the position of C in $_ ?
G> An alternative method. Position is given from a human perspective.
what is that supposed to mean? he wants it in the program, not in a human.
G> $request = "x";
G> &Find_It;
passing in globals to a sub is stupid, even in a short test example.
G> sub Find_It
G> {
G> $found = 0;
G> for ($iterate = 1; $iterate <= (length ($string)); $iterate++)
G> {
G> $found = index ($string, $request, $found);
G> if ($found gt -1)
G> { $found++; print "$request is character number $found\n"; }
now that is truly brainless. index already tells you where the string
starts. so why do your own loop and run index at each spot? mamma mia!
what next, addition like this:
$a = 3 ;
$b = 4 ;
while ( $a > 0 ) {
$b = $b + 1 ;
$a = $a - 1 ;
}
same horrendous logic.
finally, show me a SINGLE regex in your code. the OP said (copied from
above):
>> Is it possible to get the position of the matched part in a string?
>> $_ = 'ABCDE'; if (/C/) { print "C is at the 3rd character". }
no index being called, just a simple regex. the correct asnwer is to use
the pos() function with the /g regex modifier. it will tell you where
end of the regex match occured.
$_ = 'ABCDE';
if ( /C/g ) { print "C is at the ", pos() - 1, " character." }
also in 5.6 the @+ and @- variables contain the indexes of the matched
groups. read perlvar for more on that.
simple question, two correct and simple answers. that is all he
wanted. why can't you ever just do that?
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sun, 25 Jun 2000 20:22:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Get the matched position in regexp
Message-Id: <3956CC8E.DEA7188E@stomp.stomp.tokyo>
Uri Guttman wrote:
(snipped)
Get your dirty diapers in any tighter of
a knot, little boy, you are liable to suffer
a fatal brain fart.
Godzilla!
------------------------------
Date: Mon, 26 Jun 2000 02:46:03 GMT
From: "Rob" <email@address.com>
Subject: Re: matching question (http related)
Message-Id: <Ltz55.4411$Sn2.29606@news-server.bigpond.net.au>
Ugh ... overcoding ... what is wrong with this
s/.+\///g;
and if you really need the perpending '/' ...
$_ = "/" . $_;
Rob
--
The email address should read rob at cowsnet dot com
<purl_gurl@my-deja.com> wrote in message news:8j5ofi$6j$1@nnrp1.deja.com...
> In article <8j5lls$u6q$1@nnrp1.deja.com>,
> cavenewt@my-deja.com wrote:
>
>
> > I'm trying to match the 'rightmost' pattern in a string
>
> > so if I have
> > http://www.nethole.com/bongo/junior.html it would match to
> > /junior.html
>
> > if I have
> > http://www.nethole.com/bongo/fred it would match to /fred
>
> > if I have
> > http://www.nethole.com/ it would match to /
>
> > the variants of \/$ seem to grab the left most / character.
> > I want the right most.
>
> > If you have suggestions, please e-mail a reply
>
>
> Sure... as if..
>
>
> * snaps her fingers *
>
> Wallah! Piece of Marie Antoinette cake.
>
>
>
> PRINTED RESULTS:
> ________________
>
> Old String: http://www.nethole.com/bongo/junior.html
> New String: /junior.html
>
> Old String: http://www.nethole.com/bongo/fred
> New String: /fred
>
> Old String: http://www.nethole.com/
> New String: /
>
> Done! Godzilla Rocks!
>
>
> TEST SCRIPT:
> ____________
>
> #!/usr/local/bin/perl
>
> print "Content-Type: text/plain\n\n";
>
> $string = "http://www.nethole.com/bongo/junior.html";
>
> &Right_Side;
>
> $string = "http://www.nethole.com/bongo/fred";
>
> &Right_Side;
>
> $string = "http://www.nethole.com/";
>
> &Right_Side;
>
>
> sub Right_Side
>
> {
> print "Old String: $string\n";
> $position = rindex ($string, "/");
> $length = length ($string);
> $fetch = ($length - $position);
> $new_string = substr ($string, $position, $fetch);
> print "New String: $new_string\n\n";
> }
>
> print "Done! Godzilla Rocks!";
>
> exit;
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 20:31:55 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: matching question (http related)
Message-Id: <3956CEAB.25F344F@stomp.stomp.tokyo>
Rob wrote:
> Ugh ... overcoding ... what is wrong with this
> s/.+\///g;
> and if you really need the perpending '/' ...
> $_ = "/" . $_;
Egyptian hieroglyphics, unreadable technogeekster
gibberish affording no understanding nor learning.
Bottom line, Code Cop Mule Manure, Copy and Paste
Baby Blatherings. I'll write my code any ol' way
I please. It's my code, not yours. I am a programmer,
not a copy and paste technician. Besides, your code
doesn't do jack but sit there looking incomprehensible
and, if I try to run that, it will crash, won't even
compile on an Etch-A-Sketch.
Godzilla!
------------------------------
Date: Mon, 26 Jun 2000 04:16:23 GMT
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: matching question (http related)
Message-Id: <3956D923.8EFEFBBF@stomp.stomp.tokyo>
Rob wrote:
> Ugh ... overcoding ... what is wrong with this
> s/.+\///g;
> and if you really need the perpending '/' ...
> $_ = "/" . $_;
=====================
A decent article:
This code deletes everything up to and
including the last / in a string.
$_ =~ s/.+\///g;
Note the / being matched needs to be
escaped by a backslash, \/
Of course you will have to add this / back
in, according to your original question,
as shown by my prepend line:
$_ = "/" . $_;
(input = /input)
$_ represents your input, in case this
is not clear to you or others.
To stay within your requested information,
this might be better suited to meet your
needs as delineated:
$string =~ s/.+(\/)/$1/g;
However, there is a shorter better way of
doing this by replacing your / / / in a
substitution operator:
$string =~ s!.+(/)!$1!g;
Now you have a sweet and simple one line
code which does precisely what you want.
PRINTED RESULTS:
________________
Results: /junior.html
Results: /fred
Results: /
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = "http://www.nethole.com/bongo/junior.html";
&Test_It;
$string = "http://www.nethole.com/bongo/fred";
&Test_It;
$string = "http://www.nethole.com/";
&Test_It;
sub Test_It
{
$string =~ s!.+(/)!$1!g;
print "Results: $string \n\n";
}
exit;
* smiles *
There, toss in your own explanation of
what your code does and how it does it,
write a bit of test code and results,
you have an article worth reading.
What is wrong is your original article
is it is nothing more than geekster symbols
plastered on my screen.
Don't ya just get annoyed with English
teachers who have high expectations and
expect people to afford effort and work?
I write my sample programs to impart as
much information as possible going well
beyond an author's question. I write to
an audience, I write worthwhile articles.
I write to afford understanding and as
much learning as possible.
Godzilla!
------------------------------
Date: Mon, 26 Jun 2000 04:29:07 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: matching question (http related)
Message-Id: <3956da94.137007431@nntp.idsonline.com>
cavenewt@my-deja.com wrote:
>I'm trying to match the rightmost / character followed by everything
>after it.
>
>so if I have
>http://www.nethole.com/bongo/junior.html it would match to
>/junior.html
If the string is in $_:
($match) = m{(/[^/]*)$};
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 26 Jun 2000 04:29:57 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: matching question (http related)
Message-Id: <8j6m85$68q7d$1@fu-berlin.de>
hi,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Rob wrote:
>
>> Ugh ... overcoding ... what is wrong with this
>> s/.+\///g;
>> and if you really need the perpending '/' ...
>> $_ = "/" . $_;
> A decent article:
> This code deletes everything up to and
> including the last / in a string.
> [...]
so, why do you write to newsgroups? you should write
for newspapers...
a newgroup article doesn't need to be an excellent essay,
and it doesn't need to be a tutorial.
because there are enough code exmples in the perl-documentation.
> $_ =~ s/.+\///g;
why the /g? .+ is greedy, so it will match exactly once.
no need for the global match.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Sun, 25 Jun 2000 21:40:48 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: matching question (http related)
Message-Id: <3956DED0.EE03E21@stomp.stomp.tokyo>
Tina Mueller wrote:
> > $_ =~ s/.+\///g;
> why the /g? .+ is greedy, so it will match exactly once.
> no need for the global match.
Beats me. It is not my code. This is another's
code sample. Ask him.
Godzilla!
------------------------------
Date: Mon, 26 Jun 2000 05:16:14 GMT
From: "Rob" <email@address.com>
Subject: Re: matching question (http related)
Message-Id: <yGB55.4508$Sn2.30232@news-server.bigpond.net.au>
Agreed the /g is excessive ... nevertheless ... the code snippet of
$_ =~ s/.+\//;
$_ = "/" . $_
where $_ contained the original HTTP string is still FAR shorter, faster and
less cumbersome than the ridiculously long code previously posted ...
Regex matching offers great flexibility ... why reinvent the wheel ...
Rob
--
The email address should read rob at cowsnet dot com
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3956DED0.EE03E21@stomp.stomp.tokyo...
> Tina Mueller wrote:
>
> > > $_ =~ s/.+\///g;
>
> > why the /g? .+ is greedy, so it will match exactly once.
> > no need for the global match.
>
> Beats me. It is not my code. This is another's
> code sample. Ask him.
>
> Godzilla!
------------------------------
Date: Mon, 26 Jun 2000 05:17:43 GMT
From: "Rob" <email@address.com>
Subject: Re: matching question (http related)
Message-Id: <XHB55.4509$Sn2.30275@news-server.bigpond.net.au>
If you were able to write such a short and direct coding answer, why had you
not done this previously ... your ability to confuse, cloud and otherwise
misdirect is astounding ...
Rob
--
The email address should read rob at cowsnet dot com
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3956D923.8EFEFBBF@stomp.stomp.tokyo...
> Rob wrote:
>
> > Ugh ... overcoding ... what is wrong with this
>
> > s/.+\///g;
>
> > and if you really need the perpending '/' ...
>
> > $_ = "/" . $_;
>
>
> =====================
>
> A decent article:
>
> This code deletes everything up to and
> including the last / in a string.
>
> $_ =~ s/.+\///g;
>
> Note the / being matched needs to be
> escaped by a backslash, \/
>
>
> Of course you will have to add this / back
> in, according to your original question,
> as shown by my prepend line:
>
> $_ = "/" . $_;
>
> (input = /input)
>
> $_ represents your input, in case this
> is not clear to you or others.
>
> To stay within your requested information,
> this might be better suited to meet your
> needs as delineated:
>
> $string =~ s/.+(\/)/$1/g;
>
> However, there is a shorter better way of
> doing this by replacing your / / / in a
> substitution operator:
>
> $string =~ s!.+(/)!$1!g;
>
> Now you have a sweet and simple one line
> code which does precisely what you want.
>
>
> PRINTED RESULTS:
> ________________
>
> Results: /junior.html
>
> Results: /fred
>
> Results: /
>
>
> TEST SCRIPT:
> ____________
>
> #!/usr/local/bin/perl
>
> print "Content-Type: text/plain\n\n";
>
> $string = "http://www.nethole.com/bongo/junior.html";
>
> &Test_It;
>
> $string = "http://www.nethole.com/bongo/fred";
>
> &Test_It;
>
> $string = "http://www.nethole.com/";
>
> &Test_It;
>
> sub Test_It
> {
> $string =~ s!.+(/)!$1!g;
> print "Results: $string \n\n";
> }
>
> exit;
>
>
>
>
> * smiles *
>
> There, toss in your own explanation of
> what your code does and how it does it,
> write a bit of test code and results,
> you have an article worth reading.
>
> What is wrong is your original article
> is it is nothing more than geekster symbols
> plastered on my screen.
>
> Don't ya just get annoyed with English
> teachers who have high expectations and
> expect people to afford effort and work?
>
> I write my sample programs to impart as
> much information as possible going well
> beyond an author's question. I write to
> an audience, I write worthwhile articles.
> I write to afford understanding and as
> much learning as possible.
>
> Godzilla!
------------------------------
Date: Mon, 26 Jun 2000 05:20:01 GMT
From: "Rob" <email@address.com>
Subject: Re: matching question (http related)
Message-Id: <5KB55.4515$Sn2.30109@news-server.bigpond.net.au>
nicest solution yet ... :)
Rob
--
The email address should read rob at cowsnet dot com
"Keith Calvert Ivey" <kcivey@cpcug.org> wrote in message
news:3956da94.137007431@nntp.idsonline.com...
> cavenewt@my-deja.com wrote:
>
> >I'm trying to match the rightmost / character followed by everything
> >after it.
> >
> >so if I have
> >http://www.nethole.com/bongo/junior.html it would match to
> >/junior.html
>
> If the string is in $_:
>
> ($match) = m{(/[^/]*)$};
> --
> Keith C. Ivey <kcivey@cpcug.org>
> Washington, DC
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Sun, 25 Jun 2000 22:46:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: matching question (http related)
Message-Id: <3956EE27.20764800@stomp.stomp.tokyo>
Rob wrote:
> If you were able to write such a short and direct coding answer,
> why had you not done this previously ... your ability to confuse,
> cloud and otherwise misdirect is astounding ...
I am not impressed by personal insults within rhetoric.
This is an earmark of less intelligent people. I am even
less impressed, actually annoyed, by those who elect to
include lies within rhetoric. This is an earmark of
people with diminished self-confidence and an earmark
of people lacking in a sound code of ethics.
It's mule manure.
It appears you might be lacking in reading comprehension
skills. This is evidenced by my frequent preample for my
articles, in so many words,
"An alternative method than the usual."
Your response suggests to me you do not comprehend
what an "alternative method" constitutes, thus, it
is easy to surmise, you are facing, to a measured
degree, challenges in reading comprehension.
As alternative methods, I offer different ways of
accomplishing a task. This is done because I know
a hundred and one spotted obsessive technogeeks will
post an equal number of the usual copy and paste code,
over and over and over, again and again.
My thinking is not like yours and others here. I think
sidewards, in tangents, backwards and upside down. This
is why my code is unique, different and affords many
different exercises in learning. My type of thinking
is quite challenging, quite imaginative.
You, others, are stuck with use strict thinking and
strapped with warnings training wheels. You are clones
of each other; Borgs. Disconnect yourself sometime and
try a bit of imaginative thinking. You will find this
type of thinking to be most challenging, a type of
challenge of which I am obsessive.
Imaginative and creative thinking is what sorts
programmers from copy and paste technicians.
Godzilla!
------------------------------
Date: Sun, 25 Jun 2000 23:38:29 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: matching question (http related)
Message-Id: <mbudash-2506002338290001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <8j5ofi$6j$1@nnrp1.deja.com>, purl_gurl@my-deja.com wrote:
> In article <8j5lls$u6q$1@nnrp1.deja.com>,
> cavenewt@my-deja.com wrote:
>
>
> > I'm trying to match the 'rightmost' pattern in a string
>
> > so if I have
> > http://www.nethole.com/bongo/junior.html it would match to
> > /junior.html
>
> > if I have
> > http://www.nethole.com/bongo/fred it would match to /fred
>
> > if I have
> > http://www.nethole.com/ it would match to /
>
> > the variants of \/$ seem to grab the left most / character.
> > I want the right most.
>
> > If you have suggestions, please e-mail a reply
>
>
> Sure... as if..
>
>
> * snaps her fingers *
>
> Wallah! Piece of Marie Antoinette cake.
>
>
>
> PRINTED RESULTS:
> ________________
>
> Old String: http://www.nethole.com/bongo/junior.html
> New String: /junior.html
>
> Old String: http://www.nethole.com/bongo/fred
> New String: /fred
>
> Old String: http://www.nethole.com/
> New String: /
>
> Done! Godzilla Rocks!
>
>
> TEST SCRIPT:
> ____________
>
> #!/usr/local/bin/perl
>
> print "Content-Type: text/plain\n\n";
>
> $string = "http://www.nethole.com/bongo/junior.html";
>
> &Right_Side;
>
> $string = "http://www.nethole.com/bongo/fred";
>
> &Right_Side;
>
> $string = "http://www.nethole.com/";
>
> &Right_Side;
>
>
> sub Right_Side
>
> {
> print "Old String: $string\n";
> $position = rindex ($string, "/");
> $length = length ($string);
> $fetch = ($length - $position);
> $new_string = substr ($string, $position, $fetch);
> print "New String: $new_string\n\n";
> }
>
> print "Done! Godzilla Rocks!";
>
> exit;
>
>
or even simpler:
$s="http://www.nethole.com/bongo/junior.html";
$s=~m{/[^/]*?$};
print "$&\n";
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sun, 25 Jun 2000 18:38:01 PDT
From: Larry R. Waibel <lwaibel@cwia.com>
Subject: Re: NT vs Unix detection
Message-Id: <VA.0000003c.258d71ee@cwia.com>
In article <0991de68.218de5af@usw-ex0102-014.remarq.com>, Helder wrote:
> Sorry, you have to find uname for NT. If you want, I can send
> you by email.
>
Thanks but again that's something that would have to be put on each client or
some mapped location. For now I'm just depending on an environment variable
that's in NT that's not in Unix.
------------------------------
Date: Mon, 26 Jun 2000 02:39:49 GMT
From: "Rob" <email@address.com>
Subject: Re: NT vs Unix detection
Message-Id: <Vnz55.4406$Sn2.29461@news-server.bigpond.net.au>
What about $^O ... that will suffice ...
Rob
--
The email address should read rob at cowsnet dot com
"Helder" <helderNOheSPAM@cesar.org.br.invalid> wrote in message
news:2164be04.1dfbcbcb@usw-ex0102-014.remarq.com...
> Try this:
>
> $OS=`uname`;
>
> if ($OS =~ /SunOS/)
> {
> print "Sistema SunOS.";
> }
> else
> {
> print "Outro Sistema.";
> }
>
> I am not so good in Perl. You make your improvements.
> :)
>
>
> Got questions? Get answers over the phone at Keen.com.
> Up to 100 minutes free!
> http://www.keen.com
>
------------------------------
Date: Mon, 26 Jun 2000 06:15:59 GMT
From: "Rob" <email@address.com>
Subject: Re: NT vs Unix detection
Message-Id: <zyC55.4541$Sn2.30540@news-server.bigpond.net.au>
Try this ...
use POSIX qw(uname);
($kernel, $hostname, $release, $version, $hardware) = uname();
Rob
--
The email address should read rob at cowsnet dot com
"Larry R. Waibel" <lwaibel@cwia.com> wrote in message
news:VA.0000003c.258d71ee@cwia.com...
> In article <0991de68.218de5af@usw-ex0102-014.remarq.com>, Helder wrote:
> > Sorry, you have to find uname for NT. If you want, I can send
> > you by email.
> >
> Thanks but again that's something that would have to be put on each client
or
> some mapped location. For now I'm just depending on an environment
variable
> that's in NT that's not in Unix.
>
------------------------------
Date: Sun, 25 Jun 2000 22:59:34 -0400
From: "Ryan Stewart" <stew777@email.msn.com>
Subject: on again/off again CGI prob...
Message-Id: <ORPhGqx3$GA.399@cpmsnbbsa08>
I'm having a very strange problems with the CGI's on my site. For about the
last 2 weeks it seems that half the time I check their working, the other
half their not (they've worked fine all of the time for months). When their
not I get an error saying that local server addresses (i.e. D:/...) are
incorrect... what could be causing this problem? The servers guys said they
never did anything, and it's hard to show them there is a problem since it
only happend some of the time (They think I'm nuts :) ..I've confirmed the
problem on different computers and with people over the internet though so I
know it's real. I'm pretty sure the problem is with the local server path
things since CGI's that don't use them continue to work fine, and they seem
to show up in all the errors (when it's not working). If it helps here are
some of the errors I get (when it's not working)...
---
CGI ERROR
==========================================
Error Message : fatal error: Can't locate strict.pm in @INC (@INC
contains: D:\Websites\Paintball.Org\cgi-bin\links .) at
d:/Websites/Paintball.Org/cgi-bin/Links/admin/Template.pm line 21.
BEGIN failed--compilation aborted at
d:/Websites/Paintball.Org/cgi-bin/Links/admin/Template.pm line 21.
Script Location : D:\Websites\Paintball.Org\cgi-bin\links\add.cgi
Perl Version : 5.00503
Form Variables
-------------------------------------------
Environment Variables
-------------------------------------------
CLASSPATH : d:\PVSW\BIN\psql.jar
COMPUTERNAME : EINSTEIN
COMSPEC : C:\WINNT\system32\cmd.exe
HTTP_REFERER : http://www.paintball.org/links/
INCLUDE : C:\Program Files\Mts\Include
LIB : C:\Program Files\Mts\Lib
NUMBER_OF_PROCESSORS: 1
OS : Windows_NT
OS2LIBPATH : C:\WINNT\system32\os2\dll;
PATH :
d:\PVSW\BIN;C:\Perl\bin;C:\WINNT\system32;C:\WINNT;C:\Program
Files\Mts;C:\Program Files\JavaSoft\JRE\1.2\bin;C:\Program
Files\JavaSoft\JRE\1.2\bin\classic
PATHEXT : .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PERVASIVE_PATH : d:\PVSW\BIN
PROCESSOR_ARCHITECTURE: x86
PROCESSOR_IDENTIFIER: x86 Family 6 Model 6 Stepping 5, GenuineIntel
PROCESSOR_LEVEL : 6
PROCESSOR_REVISION : 0605
REQUEST_METHOD : GET
SYSTEMDRIVE : C:
SYSTEMROOT : C:\WINNT
USERPROFILE : C:\WINNT\Profiles\Default User
VSL : d:\PVSW\BIN
WINDIR : C:\WINNT
---
'D:\Websites\Paintball.Org\cgi-bin\postings.cgi' script produced no output
---
...I hope someone can please help me figure out why this is happening (so I
can tell the server guys) and hopefully even tell me how to fix it!
THANX!
- Ryan
------------------------------
Date: Mon, 26 Jun 2000 06:26:24 GMT
From: "RainCloud Studios" <news@raincloud-studios.com>
Subject: Re: on again/off again CGI prob...
Message-Id: <kIC55.16459$Yr4.288645@news1.rdc1.tn.home.com>
> Error Message : fatal error: Can't locate strict.pm in @INC (@INC
> contains: D:\Websites\Paintball.Org\cgi-bin\links .) at
> d:/Websites/Paintball.Org/cgi-bin/Links/admin/Template.pm line 21.
> BEGIN failed--compilation aborted at
> d:/Websites/Paintball.Org/cgi-bin/Links/admin/Template.pm line 21.
Notice the slashes are different?
it needs to be...
D:/Websites/Paintball.Org/cgi-bin/links
you coded the path wrong. \ in Perl means sumpin different
------------------------------
Date: Mon, 26 Jun 2000 10:02:11 +0800
From: Bert <egberts@mac.com>
Subject: Re: Regex replacing bits & pieces of a string in one shot... how?
Message-Id: <3956B9A2.4A059E43@mac.com>
Thanks Rafael! I'll try it out
Bert
Rafael Garcia-Suarez wrote:
> >How do I write a regex expression that replaces all the codes with its
> >proper string value? All at once? Or bit by bit. becoming "string1,
> >string2, string3..."
>
> my %translate = (
> A => 'string1',
> B => 'string2',
> C => 'string3',
> );
> $mystring =~ s/(A|B|C)/$translate{$1}/g;
>
> --
> Rafael Garcia-Suarez
------------------------------
Date: Sun, 25 Jun 2000 21:30:19 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Stupid Perl 'if' Question
Message-Id: <3956dc5b$1@news.microsoft.com>
"Coolc" <clarencehj@yahoo.com> wrote in message
news:8j5r07$1pg$1@nnrp1.deja.com...
> How come the following is true?
>
> #!/usr/bin/perl
> if ( "g" == "a" ) {
> print " they match \n";
> }
> If you run this the words they match are printed..... Why...
> They clearly dont match...
Of course they match, both have the numerical value zero.
> Even if you change the if line to look like this it does the same thing.
> ---> if ( "g" = "a" )
Are you sure that you want to assign the text "a" to the text "g"?
What about reading the docu?
jue
------------------------------
Date: Mon, 26 Jun 2000 01:10:42 -0400
From: "Reinhold J. Gerharz" <PostNoEmail <i_am_not@erols.com>>
Subject: Re: test for membership in an array?
Message-Id: <sldpej53jev55@corp.supernews.com>
Can anyone program Perl? Or is a sense of humor required? <G>
"H C" <carvdawg@patriot.net> wrote in message
news:39569842.14AEF495@patriot.net...
> I don't know but I've been told....grep() works
>
> iwelch@my-deja.com wrote:
>
> > what is the recommended way to test repeatedly for existence
> > of different scalars in an array? (I know I can write a loop or turn
> > the array into a hash, but that seems somewhat inelegant for an
> > operation that is probably very standard.)
------------------------------
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 3478
**************************************