[13789] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1199 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 27 23:22:53 1999

Date: Wed, 27 Oct 1999 20:22:34 -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: <941080954-v9-i1199@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 27 Oct 1999     Volume: 9 Number: 1199

Today's topics:
        setting paths <oneillNOonSPAM@cs.uregina.ca.invalid>
    Re: setting paths <newsposter@cthulhu.demon.nl>
    Re: setting paths <oneillNOonSPAM@cs.uregina.ca.invalid>
    Re: setting paths <cassell@mail.cor.epa.gov>
        Setuid script using Net::FTP <j_f9@yahoo.com>
        several questions about perl <zzhang@bayou.uh.edu>
        several questions about perl <zzhang@bayou.uh.edu>
    Re: several questions about perl <csaba.raduly@sophos.com>
    Re: several questions about perl (Abigail)
    Re: several questions about perl c_j_marshall@my-deja.com
    Re: several questions about perl <cassell@mail.cor.epa.gov>
    Re: several questions about perl (Abigail)
    Re: SGML/HTML parsing tool (Bart Lateur)
    Re: SGML/HTML parsing tool (Abigail)
        Small install question <ruedas@geophysik.uni-frankfurt.de>
    Re: Small install question <gellyfish@gellyfish.com>
    Re: Small install question <rootbeer@redcat.com>
    Re: Small install question <ruedas@geophysik.uni-frankfurt.de>
        sort in Perl rothba@my-deja.com
    Re: sort in Perl <lr@hpl.hp.com>
        SQL statement problem PLEASE HELP! hamed53@my-deja.com
    Re: SQL statement problem PLEASE HELP! <gellyfish@gellyfish.com>
    Re: SQL statement problem PLEASE HELP! <david@gigawatt.com>
    Re: SQL statement problem PLEASE HELP! c_j_marshall@my-deja.com
    Re: SQL statement problem PLEASE HELP! <cassell@mail.cor.epa.gov>
        SRC: ... off we go to katmandu <tchrist@mox.perl.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 27 Oct 1999 12:04:14 -0700
From: oneill78 <oneillNOonSPAM@cs.uregina.ca.invalid>
Subject: setting paths
Message-Id: <00091c0e.e360392d@usw-ex0110-073.remarq.com>

Hi,
I was hoping some one can tell me why when I write a simple
hello world program the computer gives me the option of
opening it from its current loction or saving it on disk,
when all I want to do is to display Hello world on the
browser.
Thanks
Ross


* Sent from AltaVista http://www.altavista.com Where you can also find releated Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


------------------------------

Date: 27 Oct 1999 19:21:37 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: setting paths
Message-Id: <7v7jc1$bhf$1@internal-news.uu.net>

oneill78 <oneillNOonSPAM@cs.uregina.ca.invalid> wrote:

> I was hoping some one can tell me why when I write a simple
> hello world program the computer gives me the option of
> opening it from its current loction or saving it on disk,
> when all I want to do is to display Hello world on the
> browser.
> Thanks
> Ross

  Your webserver does not recognize it as a perl script? Refer
to your server's documentation for finding out how to fix
that.

Erik



------------------------------

Date: Wed, 27 Oct 1999 15:38:18 -0700
From: oneill78 <oneillNOonSPAM@cs.uregina.ca.invalid>
Subject: Re: setting paths
Message-Id: <032a80ac.1b38590b@usw-ex0110-073.remarq.com>

Thanks for responding to my message.  I am new to Perl and
CS, but do you have to go through a server, can't you just
use perl like javascript.

In article <7v7jc1$bhf$1@internal-news.uu.net>, Erik van
Roode <newsposter@cthulhu.demon.nl> wrote:
> oneill78 <oneillNOonSPAM@cs.uregina.ca.invalid> wrote:
> > I was hoping some one can tell me why when I write a
> simple
> > hello world program the computer gives me the option
> of
> > opening it from its current loction or saving it on
> disk,
> > when all I want to do is to display Hello world on
> the
> > browser.
> > Thanks
> > Ross
>   Your webserver does not recognize it as a perl
> script? Refer
> to your server's documentation for finding out how to
> fix
> that.
> Erik



* Sent from AltaVista http://www.altavista.com Where you can also find releated Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


------------------------------

Date: Wed, 27 Oct 1999 16:40:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: setting paths
Message-Id: <38178D80.9A759F06@mail.cor.epa.gov>

oneill78 wrote:
> 
> Thanks for responding to my message.  I am new to Perl and
> CS, but do you have to go through a server, can't you just
> use perl like javascript.

Yes.. and no.  The difference is that your webserver has already
been told to accept The Evil That Is JavaScript (tm) as a 
programming language.  You have to tell the server about Perl.

The ActiveState docs which come with every install include
the ActiveState [win32] FAQ which includes an entire section
on doing this for a variety of webservers.  You should have
the HTML version of this on your Start Menu after the install.

And no, I don't like the things JavaScript gets used for.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Tue, 26 Oct 1999 16:54:19 +0100
From: FT <j_f9@yahoo.com>
Subject: Setuid script using Net::FTP
Message-Id: <3815CEAB.5F55B5B7@yahoo.com>

>
> This is where it stops ($srvr has the value of "bug.studby.uio.no" (my
> computer, running wuftpd), which ping recognises as alive):
>     my($ftp) = Net::FTP->new($srvr, Debug => 1, "Timeout=5");
>

POD says 'options are passed in a hash like fashion'.
I'd try:
     Timeout => 5

Greetings,
F.



------------------------------

Date: Sun, 24 Oct 1999 21:41:43 -0500
From: "zzhang" <zzhang@bayou.uh.edu>
Subject: several questions about perl
Message-Id: <7v34bn$32q$1@Masala.CC.UH.EDU>

I have used perl over a year. Now it is my favorite programming
language. The following are some questions I have about perl.

1. What is the process of executing a perl script? Does it need a
interpreter, a compiler or both? Since some perl functions are the
wrapper functions of C functions, will a C compiler participate this
process?

2. It is said perl is usually slower than C (really?). Is there any result
of a benchmark demonstrating this? Is perl good at handling programs
of high calculation load?

3. How good is perl's garbage collection compared to lisp and java?

4. Is perl specially suitable for Evolutionary Programming (EP)?

Your answers to these questions will be appreciated.
Thanks.

Zhengdong Zhang
zzhang@bayou.uh.edu






------------------------------

Date: Mon, 25 Oct 1999 21:57:29 -0500
From: "zzhang" <zzhang@bayou.uh.edu>
Subject: several questions about perl
Message-Id: <7v35a7$301$1@Masala.CC.UH.EDU>

I have used perl over a year. Now it is my favorite programming
language. The following are some questions I have about perl.

1. What is the process of executing a perl script? Does it need a
interpreter, a compiler or both? Since some perl functions are the
wrapper functions of C functions, will a C compiler participate this
process?

2. It is said perl is usually slower than C (really?). Is there any result
of a benchmark demonstrating this? Is perl good at handling programs
of high calculation load?

3. How good is perl's garbage collection compared to lisp and java?

4. Is perl specially suitable for Evolutionary Programming (EP)?

Your answers to these questions will be appreciated.
Thanks.

Zhengdong Zhang
zzhang@bayou.uh.edu








------------------------------

Date: Wed, 27 Oct 1999 14:18:56 +0100
From: Csaba Raduly <csaba.raduly@sophos.com>
Subject: Re: several questions about perl
Message-Id: <3816FBC0.C473F4B0@sophos.com>

Abigail wrote:
> 
[snip]
> 
> Oh, and BTW, Lucifer used Java to create the hell.
> 
> Abigail

I doubt it. He wouldn't have much use of the 
"Write once, run everywhere" slogan.

Besides, Hell was created by God.
According to a little known draft of Dante's Divine Comedy,
Lucifer is chained in the innermost circle of Hell, having to program
in a language called COB... 
(the manuscript is incomplete at this point :-)

Csaba
-- 
-----BEGIN GEEK CODE BLOCK----- 
Version 3.1
GCS/>GMU d- s:- a30 C++$ UL+ P+>+++ L++ E- W+ N++ o? K? w++>$ O++$ M-
V- PS PE Y PGP- t+ 5 X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
-----END GEEK CODE BLOCK----- 

Csaba Raduly,    Software Developer (OS/2),    Sophos Anti-Virus
mailto:csaba.raduly@sophos.com            http://www.sophos.com/
US Support +1 888 SOPHOS 9            UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


------------------------------

Date: 26 Oct 1999 04:10:43 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: several questions about perl
Message-Id: <slrn81aruc.fji.abigail@alexandra.delanet.com>

zzhang (zzhang@bayou.uh.edu) wrote on MMCCXLVI September MCMXCIII in
<URL:news:7v34bn$32q$1@Masala.CC.UH.EDU>:
() I have used perl over a year. Now it is my favorite programming
() language. The following are some questions I have about perl.
() 
() 1. What is the process of executing a perl script? Does it need a
() interpreter, a compiler or both? Since some perl functions are the
() wrapper functions of C functions, will a C compiler participate this
() process?

The Perl source code will be compiled into an opcode tree. The interpreter
takes this trees and follows the instructions. The C compiler doesn't
participate anymore  - his contributions have been collected and stored
in libraries for reuse. It's kind of like a conception; you only need
the man for a few minutes, at the very beginning.

() 2. It is said perl is usually slower than C (really?). Is there any result
() of a benchmark demonstrating this? Is perl good at handling programs
() of high calculation load?

Tom: No, Perl isn't much slower than C.
Ilya: Yes, Perl is much slower than C.

It depends on what you are doing, and how you have programmed it.

() 3. How good is perl's garbage collection compared to lisp and java?

Uh, Wednesday. Yes. Or Blue. With sprinkles.

() 4. Is perl specially suitable for Evolutionary Programming (EP)?

It has been rumoured that God used Perl to create the world. Perl 1
for the first day, Perl 2 for the second, and Perl 5 for the fifth
day. Humans were created with Perl 6. Chip only thinks he's the 
creator of Perl 6, but his hands are entirely guided.

It's also true that there will never be a Perl 7. 

I leave it up to you whether this little known fact proves, or
disproves that Perl is suitable for Evolutionary Programming.

Oh, and BTW, Lucifer used Java to create the hell.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Tue, 26 Oct 1999 09:46:20 GMT
From: c_j_marshall@my-deja.com
Subject: Re: several questions about perl
Message-Id: <7v3t9c$n4h$1@nnrp1.deja.com>


>
> 2. It is said perl is usually slower than C (really?). Is there any
result
> of a benchmark demonstrating this? Is perl good at handling programs
> of high calculation load?
>


I would say that Perl is faster than C because it is possible to design
and develop something in Perl and get the bloody thing running in
production in the same year.

Which just never seems to happen when using C.



Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 27 Oct 1999 16:10:16 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: several questions about perl
Message-Id: <38178658.6F2C605D@mail.cor.epa.gov>

Csaba Raduly wrote:
> 
> Abigail wrote:
> > Oh, and BTW, Lucifer used Java to create the hell.
> 
> I doubt it. He wouldn't have much use of the
> "Write once, run everywhere" slogan.

I thought that the slogan was: 
"Write once, run reliably only on Suns and win32"

> Besides, Hell was created by God.
> According to a little known draft of Dante's Divine Comedy,
> Lucifer is chained in the innermost circle of Hell, having to program
> in a language called COB...
> (the manuscript is incomplete at this point :-)

Hmmm.  My copy of the "Inferno" (IIRC) indicates that 10 
categories of the fraudulent end up in the eighth level.
Liars, seducers, and 'evil counselors' are 3 of the 10.
Where do software hype-merchants go in this list?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: 27 Oct 1999 19:56:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: several questions about perl
Message-Id: <slrn81f7p3.66b.abigail@alexandra.delanet.com>

David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCXLVIII September
MCMXCIII in <URL:news:38178658.6F2C605D@mail.cor.epa.gov>:
&& Csaba Raduly wrote:
&& > 
&& > Abigail wrote:
&& > > Oh, and BTW, Lucifer used Java to create the hell.
&& > 
&& > I doubt it. He wouldn't have much use of the
&& > "Write once, run everywhere" slogan.
&& 
&& I thought that the slogan was: 
&& "Write once, run reliably only on Suns and win32"

Well, only if you have the appropriate version. Java isn't quite
backwards compatible, and I've seen programs that need a specific
Java plugin for Netscape to run; while others don't run unless
you use whatever is buildin in Netscape.

It's "write once, and only run it in exactly the same environment
where you build it with".

&& Hmmm.  My copy of the "Inferno" (IIRC) indicates that 10 
&& categories of the fraudulent end up in the eighth level.
&& Liars, seducers, and 'evil counselors' are 3 of the 10.
&& Where do software hype-merchants go in this list?


Well, given that Inferno comes from the place Unix comes from....



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Tue, 26 Oct 1999 12:36:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: SGML/HTML parsing tool
Message-Id: <3815a043.132918@news.skynet.be>

Abigail wrote:

>So, tell me, what does HTML::Parser do?
>
>All it does is doing a call back when encountering _tokens_.
>
>
>That's not parsing.

Then HTML::Lexer might have been a better name for the module.

-- 
	Bart.


------------------------------

Date: 26 Oct 1999 09:24:16 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: SGML/HTML parsing tool
Message-Id: <slrn81bebk.fji.abigail@alexandra.delanet.com>

Bart Lateur (bart.lateur@skynet.be) wrote on MMCCXLVII September MCMXCIII
in <URL:news:3815a043.132918@news.skynet.be>:
^^ Abigail wrote:
^^ 
^^ >So, tell me, what does HTML::Parser do?
^^ >
^^ >All it does is doing a call back when encountering _tokens_.
^^ >
^^ >
^^ >That's not parsing.
^^ 
^^ Then HTML::Lexer might have been a better name for the module.


No. Because it has no frigging clue about HTML. The only part of
HTML::Parser that isn't a misnomer is the '::'.

Tokenization of HTML cannot be done context-free. A simple example:

    <p><br><br></p>

would have 4 "tokens". But

    <script><br><br></script>

only has 3. Which you can only know if you know about HTML.



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Wed, 27 Oct 1999 16:35:05 +0200
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
Subject: Small install question
Message-Id: <38170D99.167E@geophysik.uni-frankfurt.de>

Hello,
just a small question concerning installation of Perl 5.005 on an AIX
workstation:
I have unpacked the sources in a subdir of /usr/local and done the
installation, apparently successfully. Can I remove the subdir from
where I installed now, or are some important parts of the program kept
in it? I didn't seem to do special things during configuring, but
accepted more or less all of its defaults.
Thanks in advance,
-- 
------------------------------------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics, J.W.Goethe University Frankfurt
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
------------------------------------------------------------------------


------------------------------

Date: 27 Oct 1999 20:42:56 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Small install question
Message-Id: <7v7o4g$jph$1@gellyfish.btinternet.com>

On Wed, 27 Oct 1999 11:51:18 -0700 Tom Phoenix wrote:
> On Wed, 27 Oct 1999, Thomas Ruedas wrote:
> 
>> I have unpacked the sources in a subdir of /usr/local and done the
>> installation, apparently successfully. Can I remove the subdir from
>> where I installed now, or are some important parts of the program kept
>> in it?
> 
> It could save some time later if you save your configuration by keeping a
> copy of the config.sh and Policy.sh files. But other than that, you
> shouldn't need to keep the sources around after installing. If they should
> ever turn out to be needed for anything, you can always regenerate them.
> 

He might want to keep the eg subdirectory if he wants to peruse some
venerable examples as well ;-}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


------------------------------

Date: Wed, 27 Oct 1999 11:51:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Small install question
Message-Id: <Pine.GSO.4.10.9910271144150.29843-100000@user2.teleport.com>

On Wed, 27 Oct 1999, Thomas Ruedas wrote:

> I have unpacked the sources in a subdir of /usr/local and done the
> installation, apparently successfully. Can I remove the subdir from
> where I installed now, or are some important parts of the program kept
> in it?

It could save some time later if you save your configuration by keeping a
copy of the config.sh and Policy.sh files. But other than that, you
shouldn't need to keep the sources around after installing. If they should
ever turn out to be needed for anything, you can always regenerate them.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Wed, 27 Oct 1999 21:36:35 +0200
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Small install question
Message-Id: <38175443.446B@geophysik.uni-frankfurt.de>

Thank you for the info. I will remove it then (except the 2 .sh files),
because it really eats some space on the HD.
Regards,
Thomas
-- 
------------------------------------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics, J.W.Goethe University Frankfurt
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
------------------------------------------------------------------------


------------------------------

Date: Wed, 27 Oct 1999 11:47:01 GMT
From: rothba@my-deja.com
Subject: sort in Perl
Message-Id: <7v6onk$ogn$1@nnrp1.deja.com>

Hi,

I'm looking to emulate this unix sort, "sort -u +4 -5". If anyone can
help it would be appreciated.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 27 Oct 1999 06:16:25 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: sort in Perl
Message-Id: <MPG.12809afe3a02198998a13b@nntp.hpl.hp.com>

In article <7v6onk$ogn$1@nnrp1.deja.com> on Wed, 27 Oct 1999 11:47:01 
GMT, rothba@my-deja.com <rothba@my-deja.com> says...
> I'm looking to emulate this unix sort, "sort -u +4 -5". If anyone can
> help it would be appreciated.

perlfaq4: "How can I extract just the unique elements of an array?"

perlfaq4: "How do I sort an array by (anything)?"

perldoc -f sort

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 27 Oct 1999 14:59:29 GMT
From: hamed53@my-deja.com
Subject: SQL statement problem PLEASE HELP!
Message-Id: <7v740e$15p$1@nnrp1.deja.com>

(PLEASE DONT REPLY IF YOU WANT TO SAY POSTED ON WRONG GROUP)
hi
i cant figure out a sql statement for this command:
i have 3 fields in my table:
name
last_name
company
i want to select the row that if the first letter of name was my sort
letter (name regexp "^my_sort_letter"),
but if the name didnt exist then if the first letter of last_name
matched my sort letter,
and if no name or no last_name exist then same for company....
how can i do that with one select statement?
the perl version of this command is like this: (if that helps to
underestand what i wanna do)
	if($name =~/^$sort_letter/i){
		return 1;
	}
	elsif(!$name && ($last_name =~/^$sort_letter/i)){
		return 1;
	}
	elsif(!$name && !$last_name && ($company =~/^$sort_letter/i)){
		return 1;
	}
thanks for your help
hamed


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 27 Oct 1999 20:15:20 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: SQL statement problem PLEASE HELP!
Message-Id: <7v7mgo$jm3$1@gellyfish.btinternet.com>

On Wed, 27 Oct 1999 14:59:29 GMT hamed53@my-deja.com wrote:
> (PLEASE DONT REPLY IF YOU WANT TO SAY POSTED ON WRONG GROUP)

Tough.  Consider it said.

*plonk*

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


------------------------------

Date: Wed, 27 Oct 1999 13:48:06 -0400
From: "Dave Kaufman" <david@gigawatt.com>
Subject: Re: SQL statement problem PLEASE HELP!
Message-Id: <HXGR3.54$Na1.6860@nntp1>

<hamed53@my-deja.com> wrote...
> i want to select the row that if the first letter of name was my sort
> letter (name regexp "^my_sort_letter"),
> but if the name didnt exist then if the first letter of last_name
> matched my sort letter,
> and if no name or no last_name exist then same for company....
> how can i do that with one select statement?

with MySQL, you could try (assuming sort_letter is "a"):

    select * from TableName where
        name like "a%" or
        last_name like "a%" or
        company like "a%"

or if you just like regexps,

    select * from TableName where
        name regexp "^a" or
        last_name regexp "^a" or
        company regexp "^a"

-dave






------------------------------

Date: Wed, 27 Oct 1999 15:30:07 GMT
From: c_j_marshall@my-deja.com
Subject: Re: SQL statement problem PLEASE HELP!
Message-Id: <7v75pp$2l9$1@nnrp1.deja.com>

In article <7v740e$15p$1@nnrp1.deja.com>,
  hamed53@my-deja.com wrote:
> (PLEASE DONT REPLY IF YOU WANT TO SAY POSTED ON WRONG GROUP)
> hi
> i cant figure out a sql statement for this command:
> i have 3 fields in my table:
> name
> last_name
> company
> i want to select the row that if the first letter of name was my sort
> letter (name regexp "^my_sort_letter"),
> but if the name didnt exist then if the first letter of last_name
> matched my sort letter,
> and if no name or no last_name exist then same for company....
> how can i do that with one select statement?
> the perl version of this command is like this: (if that helps to
> underestand what i wanna do)
> 	if($name =~/^$sort_letter/i){
> 		return 1;
> 	}
> 	elsif(!$name && ($last_name =~/^$sort_letter/i)){
> 		return 1;
> 	}
> 	elsif(!$name && !$last_name && ($company =~/^$sort_letter/i)){
> 		return 1;
> 	}
> thanks for your help
> hamed
>


Aha an interesting perl problem.

Now what would be the perl solution to this ?

Hmmmm.

I suggest you use
	"select name, last_name, company from tablename"

open a filehandle to the results of this query.
Split the 3 columns into your variables
Then use your perl above to get the rows you want.

There. That'll do it.

Hope that helps.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 27 Oct 1999 16:31:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: SQL statement problem PLEASE HELP!
Message-Id: <38178B63.2F2F7196@mail.cor.epa.gov>

hamed53@my-deja.com wrote:
> 
> (PLEASE DONT REPLY IF YOU WANT TO SAY POSTED ON WRONG GROUP)

Since you have gotten some answers, let me just ask 'why'?

Seriously.  Often in Usenet newsgroups, you get a bad or
just ill-informed answer when you ask in the wrong newsgroup.
Hence it is important and [theoretically] helpful to point
out such an error to the poster, presumably with some useful
guidance about places where s?he might get better replies.

When people here tell a poster to go ask in 
rec.arts.penguin.anime.bbq-sauce or whatever, it is because 
there is a better group for the question, and so the poster 
will run less of a risk of getting a wrong answer without 
proper corrections in the other newsgroup.  And wrong answers
*do* appear here on occasion.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: 26 Oct 1999 05:41:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: ... off we go to katmandu
Message-Id: <3815937b@cs.colorado.edu>

#!/usr/bin/perl -w
# 
# scatman - find turds in mantrees
# tchrist@perl.com

use strict;

my ($Manpath, $Debug);

parse_opts();

MANTREE:
for my $tree (split /:/, $Manpath) {
    debug("chdir($tree)");
    chdir($tree) || die "cannot cd to main tree $tree: $!";

    # XXX: doesn't handles openbsd recursive mandirs yet

MANDIR:
    for my $mandir ( grep { -d } <man*> ) {
        debug("chdir($tree/$mandir)");
        chdir("$tree/$mandir") || die "cannot cd to subdir $tree/$mandir: $!";

	my($dirext) = ($mandir =~ /^man(.*)/);
	my($ext, @pages);

	local *MANDIR;
	unless (opendir(MANDIR, ".")) {
	    die "$0: can't opendir . while in $tree/$mandir: $!\n";
	} 

MANPAGE:
	while (my $file = readdir(MANDIR)) {
	    next MANPAGE if $file =~ /^\.\.?$/;
	    my $path = "$tree/$mandir/$file";
	    if (-l $file) {
		my $target = readlink($file);
		debug("readlink on $path -> $target");
		unless (-f $target && -r $target) {
		    print "$path: bad symblink ($target)\n";
		}
		next MANPAGE;
	    } 
	    unless (-f $file) {
		print "$path: not a plain file\n";
		next MANPAGE;
	    } 
	    next if -d $file; # XXX 

	    unless ($file =~ /\./) {
		print "$path: doesn't smell like a manpage to me\n";
		next MANPAGE;
	    } 

	    unless ($file =~ /\.${dirext}\S*(\.(gz|Z))?$/) {
		print "$path: strange extension for this directory\n";
	    } 

	    my $openspec = ($file =~ /\.(gz|Z)$/) 
		? "gzip -dc < $file |"
		: "< $file";

	    local *FH;
	    debug("open $openspec");
	    unless (open(FH, $openspec)) {
		warn "can't open $openspec: $!\n";
		next;
	    } 

	    my($saw_TH, $saw_DOT, $over_struck);
	    local $_;
MANLINE:    
	    while (<FH>) {
		$saw_DOT += /^['.]/;
		$saw_TH += m{
		    ^ [.']		# ' unlikely but possible
		    \s*			# optional white space
		    (?:
			TH		# -man version
		     |  Dt		# -mandoc version
		    )
		    \b
		}x;
		if (/^['.]\s*so\s+(\S+)/) {
		    my $link = $1;
		    my $sofile = $link =~ m#^/# 
				    ? $link
				    : "$tree/$link"; # not $mandir!
		    debug("$path: so's to $sofile");
		    unless (-f $sofile && -r $sofile) {
			print "$path: bad solink: $link\n";
		    } 
		    next MANPAGE;
		} 
		if (!defined $over_struck) {
		    $over_struck++ if /(.)[\b]\1/;
		} 
		last if $saw_DOT && $saw_TH;
	    } 
	    close FH;
	    if ($saw_DOT) {
		unless ($saw_TH) {
		    print "$path: missing title macro\n";
		} 
	    } 
	    else {
		if ($over_struck) {
		    print "$path: this catpage should be in ",
			"$tree/cat$dirext/$file\n";
		} else { 
		    print "$path: doesn't look like nroff, maybe ",
			`file $path 2>&1` =~ /: (.*)/, "\n";
		}
	    } 

	} 
    }
}

sub debug {
    print "[ @_ ]\n" if $Debug;
} 

sub usage {
    print STDERR "@_\n" if @_;
    die "Usage: $0 [ -h ] [ -d ] [ [ -M ] [ manpath ] ]\n";
}

sub run_help {
    my $pager;
    unless ($pager = $ENV{PAGER}) {
	require Config;
					     # lint happiness.  blech.
	$pager = $Config::Config{'pager'} || $Config::Config{'pager'};  
    } 

    $pager = "/bin/cat" unless has_cmd($pager);

    if (has_cmd("pod2man") &&  has_cmd("nroff") ) {
	{ exec("pod2man $0 | nroff -man | $pager") } # lint happiness
	warn "exec of pod2man | nroff | $pager failed: $!";
    } 

    if (has_cmd("pod2text")) { 
	{ exec("pod2text $0 | $pager") } # lint happiness
	warn "exec of pod2text | $pager failed: $!";
    }

    # sucks to be you!

    if (eval q{ require Pod::Text; 1; }) {
	open (STDOUT, "| $pager") || die "no pager $pager: $!";
	# this forces a wait on child if needed
	sub END { close(STDOUT) || die "cannot close STDOUT: $!" } 
	Pod::Text::pod2text($0);
	exit 0;
    }

    # it REALLY REALLY REALLY sucks to be you!
    open 0 or die "$0: cannot open myself: $!";
    $/ = '';
    while (<0>) {
	last if /__(END|DATA)__/;  # must be careful here
    } 
    print <0>;
    exit;
} 


sub has_cmd {
    my $cmd = shift;
    for (split(/:/, $ENV{PATH})) {
	my $path = "$_/$cmd";
	return $path if -f $path && -x _;
    } 
    return;
} 

sub parse_opts {
ARG: while (@ARGV && $ARGV[0] =~ s/^-(?=.)//) {
OPT:    for (shift @ARGV) {  # getopts is for wimps
            m/^$/       && do {                             	next ARG; };
            m/^-$/      && do {                             	last ARG; };
            s/^d//      && do { $Debug++;           	    	redo OPT; };
            s/^M(.*)//  && do { $Manpath  = $1 || shift @ARGV;  next ARG; };

            m/^(h|-help)?$/  # stupid fsf broken crappy excuse for real manpages
		       	&& do { run_help();          		    exit; };

            usage("unknown option: -$_");
        }
    }

    if (@ARGV) {
	usage("Manpath set, but arguments remaining") if $Manpath;
	usage("Too many arguments") if @ARGV > 1;
	$Manpath = $ARGV[0];
    } 
    else {
	$Manpath = '/usr/man';
    } 

}

__END__

=head1 NAME

scatman - find turds in mantrees

=head1 SYNOPSIS

B<scatman> S<[ B<-h> ]> S<[ B<-d> ]> S<[ [ B<-M> ] [ I<manpath> ] ]>

=head1 DESCRIPTION

The B<scatman> program locates things in man directories that
shouldn't be there.  It looks for stray files, catpage installed
where manpage belong, non-troff files, troff files without proper
title macros, wrong symbolic links, wrong C<.so> links, manpages
installed with odd extensions, and unreadable files.

The B<-d> flag adds debugging.

The B<-M> I<manpath> flag is there for compatibility with
other manly programs.  

The B<-h> flag prints this manpage and exit.  You cannot lose
this manpage.  No more whingeing!

=head1 SEE ALSO

man(1), man(7), mandoc(7), cfman(8), noman(8)

=head1 RESTRICTIONS

This program has only been tested on the Redhat operating system.

=head1 AUTHOR

Tom Christiansen <tchrist@perl.com>

=head1 HISTORY


Version 1: 24 October 1999
-- 
    X-Windows: "The first fully modular software disaster.
	--Jamie Zawinski


------------------------------

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 1199
**************************************


home help back first fref pref prev next nref lref last post