[17757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5177 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 22 00:05:30 2000

Date: Thu, 21 Dec 2000 21:05:08 -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: <977461508-v9-i5177@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 21 Dec 2000     Volume: 9 Number: 5177

Today's topics:
    Re: assign to array of references <johnlin@chttl.com.tw>
    Re: automatic FAQ answerer idea (Tad McClellan)
    Re: automatic FAQ answerer idea (Logan Shaw)
        DBIProxy question <loy_x@yahoo.com>
        howto config windows98 dble-clk to open perl with local dtbaker_dejanews@my-deja.com
    Re: HTML parse <jhelman@wsb.com>
    Re: HTML parse <jhelman@wsb.com>
    Re: HTML parse (Tad McClellan)
    Re: HTML parse <jhelman@wsb.com>
    Re: If I don't want to 'goto' miko@idocs.com
    Re: Perl on Win32 from a unix guy. <bbollenbach@homenospam.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <jbuff1856@my-deja.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
    Re: PWS - perl (cwrites)
    Re: Reading a Directory Listing into an Array (Chris Fedde)
    Re: Sorting hash (Tad McClellan)
    Re: Sorting hash <jhelman@wsb.com>
    Re: switch/case in Perl? (Chris Fedde)
        Use of uninitialized question? <pdmos23@geocities.com>
    Re: Why are multiple zeroes true? <osiris@vast.urbanna.net>
    Re: Why are multiple zeroes true? <uri@sysarch.com>
    Re: Why do people think Perl is ugly? (Vent); was: Why  miko@idocs.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 22 Dec 2000 11:00:47 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: assign to array of references
Message-Id: <91ug9v$2gd@netnews.hinet.net>

nobull wrote
> You need an explicit loop.  If all you want is tidy looking code
> AFAIK the best you can do is something like:
>
> sub assign (\@@) { $$_ = shift for @{+shift} }
>
> my @a = ('A'..'Z');
> my @refs = \@a[7..10];
> assign @refs => ('h'..'k');
> print @a;
> __END__
> ABCDEFGhijkLMNOPQRSTUVWXYZ

Because I have seen many designs of Perl's expressions
are quite artful, when I explore and learn Perl, there are
many chances that I would ask myself
"What would Perl's expression be like for this?".

Actually, I realized I was asking for something like

    @sum += @F;

In both cases, we cannot be sparking of an explicit loop.

John Lin





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

Date: Thu, 21 Dec 2000 20:54:25 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: automatic FAQ answerer idea
Message-Id: <slrn945d2h.6gj.tadmc@magna.metronet.com>

eggrock@my-deja.com <eggrock@my-deja.com> wrote:
>I might be way off base here but...
>
>Is it possible to have some sort of prompt into the (proposed) system?
>For instance: "My clueless question"--
                   ^^^^^^^^

Think about that for a minute...

 ... it would require a clue that there _is_ a magic phrase (prompt).

So we would have to tell people about the prompt, might as well
just tell them about the FAQ directly instead.


The problem is that people will just post here, they *will not*
first find out _how_ to post here. If they did, we wouldn't
be having the problems that we are having at all.

The proposal is a technical (potential) solution to a social problem.
There is an impedance mismatch there. A social solution would
have a much better chance. Making an uncomfortable scene about
FAQ asking instead of answering the FAQ for them, for example.
But for that to be effective society-wide it would have to be
nearly universally applied, and it isn't.

Folks that try to be nice by reanswering a FAQ instead of
merely pointing to the FAQ are trying to help, but end up
hurting. They reinforce that you don't _really_ need to
check the FAQ before posting, because "some poor schmuck
whose time is less valuable than mine will read it to me".

The clpmisc situation is complicated by the dual societies that 
have come to be the norm here. The net savvy/programmer/logical 
thinker, and the web "savvy" general public that want to use 
Perl to make a spiffy web page.

A group of "experts" and a group of "pre-novices", now there's
a _big_ impedance mismatch. If the novices knew of, and followed,
standard netiquette (ie. the rules of society) then could pick
the experts brains here.

I don't see either group going away (though the experts do seem
to have thinned out a great deal). So it isn't going to change.

clpmisc will never again be like it was. It is gone. Virtual
September is here to stay.

It is sad, but that _is_ the way it is.


>IMHO, automated posts to a newsgroup are not a good thing,


Automated posts to a newsgroup are OK (IMO), within limits.

Completely automated _followups_ are not a good thing,
this is news, not IRC.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 21 Dec 2000 22:59:38 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: automatic FAQ answerer idea
Message-Id: <91un3q$l7d$1@boomer.cs.utexas.edu>

In article <t4532nfeg8o1c4@corp.supernews.com>,
Chris Stith  <mischief@velma.motion.net> wrote:
>I propose the group alt.lang.perl.askthebot be created by
>someone interested in the idea. Humans interested in the
>idea could post there, as well as anyone who thinks that
>their question may not be ready for posting to the
>comp.lang.perl.* hierarchy. 

I think this is an interesting idea, but I am sort of
philosophically opposed to the idea of creating a group that might
not be used.  It just makes more work for Usenet news admins, and
they are the type of person who is already overworked.

Therefore, I would prefer to not create such a group until there
is at least some sort of prototype of the software ready to go.

Actually, I had envisioned training/testing it in a different
way -- I'd create a web page where interested people could go
review articles that the bot picked up on along with which FAQ
question it categorized it as.  The page would have a form
that would allow people to tell the bot, "yes, that was
right", or "no, that was wrong; the correct answer is _____".

Of course, that sort of thing is not mutually exclusive
with a testbed newsgroup, but I'd prefer to do the web
thing to train the bot before starting up a newsgroup.

And either way, for the next week or so, I'm going to be
celebrating Christmas, etc. rather than writing code.  :-)

  - Logan


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

Date: Thu, 21 Dec 2000 20:00:07 -0800
From: news <loy_x@yahoo.com>
Subject: DBIProxy question
Message-Id: <3A42D1C7.343376F3@yahoo.com>

Hi,

I'm trying to use DBIProxy to enable remote access to an odbc datasource
on a win2k machine from a unix box.  I'm using perl5.6 on both sides and
all necessary modules are installed.  However when I try to connect
(using DBI->connect("dbi:Proxy:$proxy;dsn=$dsn",user ,pass ,) )  I get
the error message

DBI->connect(hostname=[myip];port=4321;dsn=dbi:ODBC:mattsdb) failed:
Constructor didn't return a handle:  at ./dbiproxytest.pl line 7

I'm starting dbiproxy with

$ dbiproxy --debug --mode=fork --logfile=STDERR
--configfile=c:/temp/dbiproxy.conf

and my configfile contains:

{
    'localport' => 4321,
    'pidfile' => 'c:\temp\dbiproxy.pid',
    'logfile' => 1,
    'debug' => 1,
    'mode' => 'fork',
    'timeout' => 60,
    'clients' => [
    {
        'mask' => '[mynetworkip]',
        'accept' => 1
    },
    {
        'mask' => '[mycanonicaldomain]',
        'accept' => 1 },
    {
        'mask' => '.',
        'accept' => 1
    }
    ]
}

On the windows side, the output generated by dbiproxy:

Thu Dec 21 19:53:07 2000 debug, Server starting in operation mode fork
Thu Dec 21 19:53:07 2000 notice, Server starting
Thu Dec 21 19:53:07 2000 debug, Writing PID to c:\temp\dbiproxy.pid
Thu Dec 21 19:53:15 2000 debug, Connection from [myip], port 4829
Thu Dec 21 19:53:15 2000 debug, Child clone:
DBI::ProxyServer=HASH(0x1f0c14c)


Any help on this would be enormously appreciated.



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

Date: Fri, 22 Dec 2000 03:34:46 GMT
From: dtbaker_dejanews@my-deja.com
Subject: howto config windows98 dble-clk to open perl with local dir as working dir?
Message-Id: <91ui4m$ckt$1@nnrp1.deja.com>

This is probably mostly a windows issue, but since it is affecting the
way I am using perl, I am hoping that some win32 perl user can help me
out on this one.

The problem is that I have one machine that I cant seem to get to use
the current . directory as the working directory when firing up a scipt
with a dble-click from an explorer window. I dont really want to add the
full path in the script, I have a couple utility scripts I just want to
be able to double-click a fire up to run on some files in the "local"
directory. I KNOW its not a good idea to assume the path, but in this
case I'd like to cheat a little.... and I'm frustrated because it works
on one. ;)

I have two windows98 machines with the same version of perl
(activestate522), and one uses the current dir as the working dir, and
the other uses the c:\usr\bin where the perl.exe is when I run a script.

I have checked the file association for the .pl extension and it looks
identical.... opening with C:\usr\bin\Perl.exe "%1" %*

I have poked around win98 help but have not found a way to set the dir
an executable opens IN.......

any ideas?

Dan


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 22 Dec 2000 02:30:55 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: HTML parse
Message-Id: <3A42BCF7.F2ABCEE2@wsb.com>

nodo70@my-deja.com wrote:

> > while ($Body =~ m!<A[^>]+HREF=(['"])([^\1]+?)\1[^>]*>(.+?)</A>!sig) {
> >       my ($link, $text) = ($2, $3);
> >       my $linkText = sprintf ("%-60s %-s\n",$link,$text);
> >       print $linkText;
> > }
> >
> But if $Body = "<a href="http://www.yourname.com"><font size=3>Your
> Name</font></a> then it would print
> http://www.yourname.com      <font size=3>Your Name</font>

Sorry, but I thought that's what you wanted (since you could have all
sorts of stuff between the <A HREF>...</A> sequence, like image tags,
etc.).  If you want to lose any HTML tags inside the $text scalar, just:

$text =~ s/<[^>]+>//g;

> I just add:
> $text =~ s/\<.+\>(.+)\<\/.+\>/$1/gsi if ($text =~ m/\>/);
> text =~ s/<\/.+\>//g;

First, you don't need to escape < or > inside a regex, since they aren't
special characters (unlike the other "bracket" type tags -- ( ) { } [
]).  Escaping them (i.e. \< and \>) doesn't hurt anything, but it just
adds useless noise to the expression and makes it harder to read.  But
don't feel bad, I did the exact same thing when I was learning Perl.

Second, the problem with your code is it's really greedy.  For example,
if you assigned:

$text = "<B>This is <I>italic</I> text.</B>";

and then ran it through the first of your regular expressions, it would
return " text." since your expression would match as follows:

 "<B>This is <I>italic</I> text.</B>"
s/<           .+         >( .+ )<.+>/$1/gsi;

Your second expression would be even worse, as it would grab everything
and return an empty string.  Remember that the expression .+ is greedy,
that is, it tries to match as much as possible.  Even if you make it a
match as little as possible (.+?), you would run into the problem in my
above example  of having the <I> and </I> tags remain.

In short, the only (easy) way to get rid of HTML tags in your return
value is to use the expression I gave you above.  (There are many much
more difficult ways, such as recursively removing matching tag pairs,
etc., but those get complex in a hurry and are superfluous for your
needs as expressed here.)

Hope this helps,
JH


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

Date: Fri, 22 Dec 2000 02:58:35 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: HTML parse
Message-Id: <3A42C373.D3A7E5F0@wsb.com>

Jerome O'Neil wrote:

> It would seem also that you are a newbie to development and programming
> in general.  When you are no longer a newbie, you will know that
> re-inventing a wheel (especialy a hard wheel) is rarely good programming
> practice.

For what it's worth, this is generally a true statement, but there are
exceptions.  For example, a few threads ago there was a discussion about
how to add the number of days in a month to a date string in the format
of YYYYMM.  One poster pointed out that using the Date::Manip module
made this a trivial exercise (which it did), but Abagail posted a rather
elegant one-liner that did the same thing.  In my way of thinking,
Abagail's solution was much more appropriate to such a trivial task,
whereas using a robust module like Date::Manip seemed to me like
swatting flies with a Buick.  Granted, nobody wants to reinvent the
wheel, but we're talking about stripping a couple of tags here, not
building a fully-functional CRM system. :)

> > Do you think it's a good coding?
> 
> No.  If your goal is to learn about manipulating HTML, then use the
> tools available to you to do so.  If your goal is to learn about
> regular expressions, there are better academic excercises than
> parsing HTML.

Again, I respectfully disagree.  As HTML is such a forgiving language,
there are almost an infinite number of gotchas that one might have to
catch, which forces the novice programmer to really explore the power of
Perl regexes.  And, not really having played with the HTML::* modules
myself, if I were in a similar spot with the same requirements, I'd
spend less time writing my own trivial hack than researching how to do
it with those modules.  Would it be as robust?  Of course not.  Would it
get the job done?  Yes.

> If men could learn from history, what lessons it might teach us!  But
> passion and party blind our eyes, and the light which experience gives
> is a lantern on the stern, which shines only on the waves behind us.
>                                 --Samuel Taylor Coleridge, "Recollections"

Very, very true.  But remember,

"There are more things in heaven and earth, Horatio,
 then are dreamt of in your philosophy."
                            -- William Shakespeare, Hamlet, Act I, Scene
5

JH


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

Date: Thu, 21 Dec 2000 21:51:39 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HTML parse
Message-Id: <slrn945gdr.6is.tadmc@magna.metronet.com>

Jeff Helman <jhelman@wsb.com> wrote:
>Jerome O'Neil wrote:

>> No.  If your goal is to learn about manipulating HTML, then use the
>> tools available to you to do so.  If your goal is to learn about
>> regular expressions, there are better academic excercises than
>> parsing HTML.
>
>Again, I respectfully disagree.  As HTML is such a forgiving language,


Eh? HTML is not at all "forgiving". It is rather rigorously described.

But most things that folks call "HTML" are not really HTML. They
are more accurately "things that display good in a browser".

Browsers are forgiving (of bad markup), not the HTML defined
by the w3c.


>there are almost an infinite number of gotchas 


They wouldn't "getcha" if it was truly "forgiving"  :-)

You must have meant "complex" or something instead?


>I'd
>spend less time writing my own trivial hack than researching how to do
>it with those modules.  Would it be as robust?  Of course not.  Would it
                                        ^^^^^^             ^^^
>get the job done?  Yes.
                    ^^^

I'm having trouble reconciling those two parts.

Maybe you just have a better job than I do...


   Would it get the job done? Sometimes.


Of course, "sometimes" may often also be "good enough".

That is the kind of thing we get paid the big bucks to decide :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 22 Dec 2000 04:13:20 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: HTML parse
Message-Id: <3A42D4F8.AE7FC6F2@wsb.com>

Tad McClellan wrote:
> 
> Jeff Helman <jhelman@wsb.com> wrote:
> >Jerome O'Neil wrote:
> 
> >> No.  If your goal is to learn about manipulating HTML, then use the
> >> tools available to you to do so.  If your goal is to learn about
> >> regular expressions, there are better academic excercises than
> >> parsing HTML.
> >
> >Again, I respectfully disagree.  As HTML is such a forgiving language,
> 
> Eh? HTML is not at all "forgiving". It is rather rigorously described.
> 
> But most things that folks call "HTML" are not really HTML. They
> are more accurately "things that display good in a browser".

I agree wholeheartedly.  But, in my mind, the fact that browsers display
"correctly" things that don't comply with the language spec, then that
indicates "forgiveness".  Does my cab driver speak the Queen's english? 
No.  Can I understand him?  Yes (usually :) ).

> Browsers are forgiving (of bad markup), not the HTML defined
> by the w3c.

Those of us in the programming profession may shun HTML that doesn't
follow spec, but, sadly, we don't rule the world.  And since HTML is
meant to be interpreted by browsers, if the VAST majority of them
support some "feature", then that "feature" will make it's way into
general usage, the spec be damned.  'Course, this has nothing to do with
Perl. :)

> >there are almost an infinite number of gotchas
> 
> They wouldn't "getcha" if it was truly "forgiving"  :-)

They very well could.  Take, for example, the HTML string "<B><I>This is
bold italic text</B></I>".  My point was that parsing this string using
matching tags to extract the values between (something like
s/<(\w+)[^>]*>(.+?)</\1>/$2/g) would get screwed up a bit by the fact
that the closing bold and italic tags were in the wrong order.  Is this
valid according to the HTML spec?  (Actually, I don't know.  Had I
written the spec, no.  But...)  But does this fragment display correctly
in the browser?  Sure.

> You must have meant "complex" or something instead?

Complex works too.  But given the example above, I still would consider
this a gotcha.

> >I'd
> >spend less time writing my own trivial hack than researching how to do
> >it with those modules.  Would it be as robust?  Of course not.  Would it
>                                         ^^^^^^             ^^^
> >get the job done?  Yes.
>                     ^^^
> 
> I'm having trouble reconciling those two parts.

Why?  (Read my comments about swatting flies with the Buick.)  Is the
one-liner less "robust" than including the full features of
Date::Manip?  Of course.  But does it do the job to specifications? 
Yes.  (And is the one liner faster?  I haven't benchmarked, but I'd bet
really good money that it is.)

> Maybe you just have a better job than I do...

Maybe... :)

>    Would it get the job done? Sometimes.
> 
> Of course, "sometimes" may often also be "good enough".

I wrote sometimes here based on my understanding of the specs.  Based on
my understanding, let me rephrase:  "Would it get the job done?  Yes." 
Anyway, I'm from Washington, D.C., home of the phrase "Good enough for
government work." :)

> That is the kind of thing we get paid the big bucks to decide :-)

True enough.  But look at the requirements given (as best I can discern
them from the poster):  Extract the URL from a link as well as the
plain-text contained within the <A..></A> set.  If I have the
requirements incorrect, I might very well choose another approach.  But
given THIS set of requirements (as I understand them), what do you find
fault with?  I believe in laziness as much as the next guy, but what I
wrote matched the requirements as I understood them.  And, as I
confessed, I haven't explored the HTML::* modules at all, so those
modules could very well not have met my needs anyway.

Sorry if I wasn't clear (God, I hate year-end deadlines),
JH


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

Date: Fri, 22 Dec 2000 03:25:38 GMT
From: miko@idocs.com
Subject: Re: If I don't want to 'goto'
Message-Id: <91uhjd$c8k$1@nnrp1.deja.com>

In article <91sd5b$ab3@netnews.hinet.net>,
  "John Lin" <johnlin@chttl.com.tw> wrote:
> Really?  Recently I tried to modify the structure of a program
> to avoid using 'goto'.
>
>     for my $file (<*>) {
>         ...
>         if($fail_condition1) { warn "message 1"; goto fail }
>         ...
>         if($fail_condition2) { warn "message 2"; goto fail }
>         ...
>         if($fail_condition3) { warn "message 3"; goto fail }
>
>         next;
>     fail:
>         rename $file => "fail/$file";  # move to fail/ sub directory
>         ... and many other statements
>     }
>
> I couldn't think of a better structure to avoid the 'goto'.


last and next are often handy in situations like you describe.  For
example, your code could be reworked like this:


 DIRLOOP:
 for my $file (<*>) {

    TESTBLOCK:
        {
        if($fail_condition1) { warn "message 1"; last TESTBLOCK;}
        if($fail_condition2) { warn "message 2"; last TESTBLOCK;}
        if($fail_condition3) { warn "message 3"; last TESTBLOCK;}

        next DIRLOOP;
        }

    rename $file => "fail/$file"; # move to fail/ sub directory
 }



-miko

--
Miko O'Sullivan
Author of The Mikodocs Guide to HTML
http://www.mikodocs.com/tags/


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 22 Dec 2000 03:23:52 GMT
From: "Brad Bollenbach" <bbollenbach@homenospam.com>
Subject: Re: Perl on Win32 from a unix guy.
Message-Id: <cPz06.53131$Z9.3146373@news1.rdc1.mb.home.com>

A Unix guy and you didn't know that perldoc -q <your faq keyword here> is
the easiest way to find answers to easy questions? Hmmmm... :)

Anyways, both:

    perldoc -q date

and

    perldoc -f localtime

will take you where you want to go! For next time, make your life easier by
using perldoc -q first :)

-- Brad

<dnay@vbs.net> wrote in message news:91tmke$lrq$1@nnrp1.deja.com...
>
>
> Hey All, This is most likely a VERY easy question but it's been giving
> me a headache for the last couple of hours. :)
>
> I usually program with perl on unix and enable to get the date I just
> call /usr/bin/date with the format that I want and use the results from
> STDOUT as my value.  The problem is that I am attempting to write a
> perlscript on Windows 2000 server now using ActiveState perl and there
> obviously is no /usr/bin/date command.
>
> So, what I want to know is what is the best way to get the date/time on
> Win32 with ActiveState perl?
>
> Any help would be very much appreciated! Thanks!
>
> Darren Nay - dnay@ibonzai.com
>
>
> Sent via Deja.com
> http://www.deja.com/




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

Date: Fri, 22 Dec 2000 03:00:55 GMT
From: jbuff <jbuff1856@my-deja.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.3 $)
Message-Id: <91ug55$b83$1@nnrp1.deja.com>

In article <slrn942go9.3mb.tadmc@magna.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
>
> Here are the Posting Guidelines as they currently stand.
> Comments on its content are solicited.
>

Speaking as the lurker who posted the suggestion that helped to spur
Tad into this project, I am quite satisfied with this version.

I'd be more than happy to post a copy at my site just to show the
denizens of the newsgroup that I participate in most frequently
(alt.dbs.echostar) how easygoing we are about posting style in contrast
to many other groups.

Thanks for all the hard work, I'm sure I won't make any social errors
if and when I finally have a perl question that I need to ask here.

It should be noted that by following these guidelines, I've avoided the
need to post questions completely so far.

--jbuff


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 21 Dec 2000 21:35:02 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.3 $)
Message-Id: <slrn945fem.6is.tadmc@magna.metronet.com>

jbuff <jbuff1856@my-deja.com> wrote:
>In article <slrn942go9.3mb.tadmc@magna.metronet.com>,
>  tadmc@metronet.com (Tad McClellan) wrote:
>>
>> Here are the Posting Guidelines as they currently stand.
>> Comments on its content are solicited.


>It should be noted that by following these guidelines, I've avoided the
>need to post questions completely so far.


That was the whole idea :-)

Be free of slavish dependence on handouts from others.

Become self-sufficient, and get answers *faster* in the bargain!

A win-win situation.

Glad it helped.



P.S. If you ever do need to post a question, you might consider
     switching to some other way of accessing news. The domain
     you are using will restrict the readership of your articles...


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 22 Dec 2000 04:49:12 GMT
From: bconnats@bellsouth.net (cwrites)
Subject: Re: PWS - perl
Message-Id: <3a42dc5a.21117033@news.lig.bellsouth.net>

Hello. Of course your problem is related to Perl. I had the same
problem. I followed the directions in ActiveState, but I couldn't get
it going. Finally, someone from a different newsgroup gave me the
answer. I had to add the path to my Perl interpreter to the Windows
system bat file. That was about three months ago, so I have forgotten
the process. But it worked. I'm able to test CGI scripts (written in
Perl, of course) with my PWS. I hope that someone here can tell you
how to add the path to your bat file.

Brad

On 20 Dec 2000 18:46:53 +0000, nobull@mail.com wrote:

>"Sven Franke" <snefsite@hotmail.com> writes:
>
>> Hi, I hope you guys can help me out.
>
>Maybe some of us could but it would be considerd a bad thing for us to
>do so as we don't want to encourage off-topic posting.
>
>> I use W98(se) and I installed PWS.
>
>> I wrote a little HELLO WORLD (try.cgi) and placed this file into CGI-BIN.
>> 
>> When I go to http://localhost/CGI-BIN/try.cgi the page cannot be displayed
>> or the file is shown totally.
>
>What you have here is a PWS configuration question - not related to
>Perl.  You must somehow tell PWS that files in CGI-BIN with a .cgi
>suffix are to be interpreted using perl.exe.  Or alternatively perhaps
>you can persuade PWS to honour #! headers.  I don't know because I
>know nothing about PWS.
> 
>> What is wrong? I looked at activestate, but the help overthere wasn't
>> solving my problem.
>
>Because your problem is not Perl related.
>
>-- 
>     \\   ( )
>  .  _\\__[oo
> .__/  \\ /\@
> .  l___\\
>  # ll  l\\
> ###LL  LL\\



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

Date: Fri, 22 Dec 2000 03:02:51 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Reading a Directory Listing into an Array
Message-Id: <vvz06.402$B9.188713472@news.frii.net>

In article <slrn944hnc.ed9.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>Lauri Palokangas (Lauri.Palokangas@Nokia.REMOVETHIS.COM.invalid) wrote on
>MMDCLXIX September MCMXCIII in
><URL:news:3A4252D3.5FD153B0@Nokia.REMOVETHIS.COM.invalid>:
>`` Some_Indiana_Guy wrote:
>`` 
>`` > Does anyone know a simple function to read a directory listing into an
>`` > array?
>`` 
>`` I don't know the easier way than:
>`` --- CLIP ---
>``  my ($path,@filelist);
>``  $path="/path/to/dir";
>``  opendir(PATH,$path) or die "Can't open dir: $!\n";
>``  @filelist=readdir(PATH);
>``  closedir PATH;
>`` --- CLIP ---
>
>
>Much simpler:
>
>    @list = `ls`;  # or `ls -a`;
>

Or perhaps a different approach?

    use Shell;
    @list = ls(-aq);

chris
-- 
    This space intentionally left blank


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

Date: Thu, 21 Dec 2000 21:16:41 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Sorting hash
Message-Id: <slrn945ec9.6gj.tadmc@magna.metronet.com>

Jeff Helman <jhelman@wsb.com> wrote:
>bkesuma@yahoo.com wrote:
>
>> foreach $email (sort keys %COUNT){
>>     print "$email = $COUNT{$email}\n";
>> }
>
>You could do one of two things here.


Neither of which you should do.

You should instead do it as in the FAQ.

   
   "How do I sort a hash (optionally by value instead of key)?"


Which is exactly the question the OP asked.


>So instead, build an intermediate hash 


No! Just sort it the way you want it sorted in the first place.

Temp vars suck. 

More variables means more stuff for you to maintain, more chances
of making a mistake...


>Hope this helps,


Attempting to reanswer a FAQ rarely helps.

Your attempt was not one of the rare ones  :-)

Please do not try and reanswer FAQs. Just tell them where
the FAQ is that addresses their problem.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 22 Dec 2000 03:25:09 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Sorting hash
Message-Id: <3A42C9AE.925DF5F9@wsb.com>

Tad McClellan wrote:

> Attempting to reanswer a FAQ rarely helps.
> 
> Your attempt was not one of the rare ones  :-)
> 
> Please do not try and reanswer FAQs. Just tell them where
> the FAQ is that addresses their problem.

I apologize.  I was not aware that this was, indeed, a FAQ.  Shows that
old dogs can learn new tricks.  Thanks,

JH


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

Date: Fri, 22 Dec 2000 04:11:25 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: switch/case in Perl?
Message-Id: <NvA06.403$B9.188798976@news.frii.net>

In article <47i34tgjo2mtek9433k64v64pongll8au9@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>Andrew N McGuire wrote:
>
>>I want 'a' and 'A' to be equivalent, so the
>>fall through is natural.
>
>You can't convince me, I'm too stubborn. I find C's switch syntax
>incredibly primitive. What would have been wrong with a syntax, as in
>(extended) BASIC:
>

What we always seem to forget, is that languages like BCPL, B, C
and C++ were developed by people who were designing programming
environments for digital telephone switches.  Small fast languages
for critical real time environents that bind close to the hardware
while still supporting high level programming features.
-- 
    This space intentionally left blank


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

Date: Fri, 22 Dec 2000 04:06:36 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: Use of uninitialized question?
Message-Id: <3A42D42C.4395F934@geocities.com>

I've been doing quit well programming with DBI & Access,  but I have
come across a persistent warning, "Use of uninitialized value in string
eq at C:\directory\cgi-bin\scriptname.pl line 72."  The values below
obviously come from a form's input.  Then they are shown on a summary
page after the conditional stmt.
The code being used is:
my $age = param('age');
my $adr = param('adr');

### further down the page
if (($age eq "") || ($age eq undef)) {
 $age = "Not entered";
}
if (($adr eq "") || ($adr eq undef)) {
 $adr = "Not entered";
}
and so on.....

My first question, I'm not sure about the "($variablename eq undef)"?
Is this OK?
Secondly, how else can this be done?  Aren't the variables defined after
the conditional stmt?

Thanks,
Pasquale



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

Date: Thu, 21 Dec 2000 22:07:14 -0500
From: Michael Erskine <osiris@vast.urbanna.net>
Subject: Re: Why are multiple zeroes true?
Message-Id: <3A42C562.BE4B43D3@vast.urbanna.net>

miko@idocs.com wrote:
> 
> In article <x7zohygpod.fsf@home.sysarch.com>,
>   Uri Guttman <uri@sysarch.com> wrote:
> 
> > it all makes sense and you should trust larry's judgement on this.
> > it has been this way for years and all experienced perl hackers
> > know it and understand it. this question only comes from newbies
> > who haven't learned enough perl yet.

I am most certainly no perl wizard, but like Larry I am a linguist, and
I am a Computer Scientist...  this foolishness of multiple 0's being true
is not reasonable, period.

> 
> I do trust Larry's judgement, but it's hardly the path to the best world
> to never question things.  As Larry says, "We question most of the
> mantras around here periodically."
> 

Even so, it is Larry's design.  If he so chooses to make multiple 0's be
true, he so chooses.  I am working with perl, still learning it actually,
but I have never seen any other language (or reality for that matter) in
which this is the case...

It is simply not reasonable.  If on the other hand, if it is an entrenched
'feature' of the language, it might be dangerous to remove it.  That is
the Computer Scientist speaking and not the linguist, a situation which
was probably reversed in the initial decision (or lack thereof, which is
much more likely).

You get the drift, right Larry?


--
Shortly after the 1967 Mideast War, a young girl asked Ms. Golda Meyer
when there would be peace in the middle east.  Ms. Meyer responded, 
"There will never be peace in the middle east so long as we hate our
enemies more than we love our children."


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

Date: Fri, 22 Dec 2000 04:58:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why are multiple zeroes true?
Message-Id: <x7y9x9cask.fsf@home.sysarch.com>

>>>>> "m" == miko  <miko@idocs.com> writes:

  m> In article <3a3a3cc9@cs.colorado.edu>,
  m>   tchrist@perl.com (Tom Christiansen) wrote:

  >> It's cleanest to thing of there being just two false values in Perl:
  >> zero and the null string--thus, anything that reduces to one of
  >> these is itself false.  I like thinking of it like this because
  >> it's easier to remember just 2 rules than the 4, 5, or even 6 that
  >> you often see people cite.

  m> Well, that's exactly the reason that led to me expect "000" to be false:
  m> it fits into the first rule of reducing to zero (as it does in a numeric
  m> context).  To make "0" false but "000" true you have use more
  m> complicated rules.

you are going backwards. starting with undef you can get to '', 0 and
then to '0'. you cannot generate '00' from those with just context.

so those 4 false values are consistant with each other and with no
others being false. boolean contexts do not convert strings to numbers
and vice versa. they will convert an undef to '' or 0. so '00' in a
boolean context is just another string that is not '0' so it is true.

and one other point, it is much faster to check a string is '0' then for
any multiple zero string. since boolean tests are so common, it is a
good thing that false is limited to only those 4 values. 

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: Fri, 22 Dec 2000 02:11:17 GMT
From: miko@idocs.com
Subject: Re: Why do people think Perl is ugly? (Vent); was: Why isn't Perl highly orthogonal?
Message-Id: <91ud83$90n$1@nnrp1.deja.com>

In article <t3ahqorlds4q72@corp.supernews.com>,
  cberry@cinenet.net (Craig Berry) wrote:

> Of course, an artist will be horribly constrained by the
> etch-a-sketch

I can't help mentioning that I once knew an artist whose medium of
choice actually was the Etch-a-Sketch.  He created amazingly detailed
and vivid drawings, mostly of rock stars, then emptied the remaining
sand out, glued the knobs in place, and sold the sketches.  I guess you
just never know what medium will turn someone on.  If you had told the
13 year old writer/artist that was me that I would one day consider a
computer network as my artistic medium, I would have laughed, but it has
come to pass.

[We now return you to your regularly scheduled Perl discussion, already
in progress...]

-miko


--
Miko O'Sullivan
Author of The Mikodocs Guide to HTML
http://www.mikodocs.com/tags/


Sent via Deja.com
http://www.deja.com/


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

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


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