[16294] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3706 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 09:12:44 2000

Date: Tue, 18 Jul 2000 06:12:33 -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: <963925952-v9-i3706@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3706

Today's topics:
        [NEW-B] What's wrong with this script? (Kliffoth)
    Re: [NEW-B] What's wrong with this script? (Brian)
    Re: [NEW-B] What's wrong with this script? (Kliffoth)
    Re: [NEW-B] What's wrong with this script? (Michael Budash)
    Re: [NEW-B] What's wrong with this script? (Ala Qumsieh)
    Re: [NEW-B] What's wrong with this script? (Kliffoth)
    Re: [NEW-B] What's wrong with this script? (Bart Lateur)
    Re: [NEW-B] What's wrong with this script? (Kliffoth)
    Re: [NEW-B] What's wrong with this script? (Larry Rosler)
    Re: [NEW-B] What's wrong with this script? (Abigail)
        [NEWBI] Reg Exp request for help (Ken Loomis)
    Re: [NEWBI] Reg Exp request for help (Ecco)
    Re: [NEWBI] Reg Exp request for help (Godzilla!)
    Re: [NEWBI] Reg Exp request for help (Keith Calvert Ivey)
    Re: [NEWBI] Reg Exp request for help (Stephen Kloder)
    Re: [NEWBI] Reg Exp request for help (Craig Berry)
    Re: [NEWBI] Reg Exp request for help (Keith Calvert Ivey)
        [Perl] How to find the Perl FAQ (Tom Phoenix)
        accessing perldoc without having to telnet? <raphaelp@nr1webresource.com>
    Re: accessing perldoc without having to telnet? <raphaelp@nr1webresource.com>
    Re: Accessing string (Bart Lateur)
        Active State Perl on IIS 4.0 (Oleg Kuzmin)
    Re: Active State Perl on IIS 4.0 ()
    Re: Activestate PPM not working for Windows? (Eric Archuleta)
        Advanced Regexp Parsing HELP! Please (Nathan Wiger)
    Re: Advanced Regexp Parsing HELP! Please (Andrew Johnson)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 17 Jul 2000 01:40:00 GMT
From: ?@?.?.bbs@openbazaar.net (Kliffoth)
Subject: [NEW-B] What's wrong with this script?
Message-Id: <3bQh50$XHu@openbazaar.net>

I wrote a script to look at an array of loose words, then print "okay" if
the word "bla" is in the array, but I just keep getting "okay" wether the
word is in the array or not, and I just can't find out where the problem is
:-(


foreach $WORD (@WORD_LIST)
         {
         $LOW_WORD = lc $WORD;
         $HASH{$LOW_WORD} = 1;
         }

if ($HASH{'bla'} = 1)
         {
         print "okay";
         }
else
        {
        print "not okay";
        }


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

Date: 17 Jul 2000 01:50:02 GMT
From: bt@nospam.com..bbs@openbazaar.net (Brian)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bQhHQ$W9_@openbazaar.net>

On Mon, 17 Jul 2000 01:40:04 GMT, "Kliffoth" <?@?.?> wrote:

>I wrote a script to look at an array of loose words, then print "okay" if
>the word "bla" is in the array, but I just keep getting "okay" wether the
>word is in the array or not, and I just can't find out where the problem is
>:-(
>
>foreach $WORD (@WORD_LIST)
>         {
>         $LOW_WORD = lc $WORD;
>         $HASH{$LOW_WORD} = 1;
>         }
>
>if ($HASH{'bla'} = 1)
>         {
>         print "okay";
>         }
>else
>        {
>        print "not okay";
>        }

Try if ($HASH{'bla'} == 1)

You're assigning 1 to HASH{'bla'} and the 'if' is evaluating if the assignment
worked or not.

I can't believe I could answer a question in this forum :)

Brian.


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

Date: 17 Jul 2000 01:50:02 GMT
From: ?@?.?.bbs@openbazaar.net (Kliffoth)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bQhHR$WDz@openbazaar.net>

I WAS SOOOO STUPID!!!! THANX MICHAEL!

--
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/free_video/

"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-1607001844250001@adsl-216-103-91-123.dsl.snfc21.pacbell.net...
> In article <Uttc5.398456$k22.1761341@flipper>, "Kliffoth" <?@?.?> wrote:
>
> > I wrote a script to look at an array of loose words, then print "okay"
if
> > the word "bla" is in the array, but I just keep getting "okay" wether
the
> > word is in the array or not, and I just can't find out where the problem
is
> > :-(
> >
> >
> > foreach $WORD (@WORD_LIST)
> >          {
> >          $LOW_WORD = lc $WORD;
> >          $HASH{$LOW_WORD} = 1;
> >          }
> >
> > if ($HASH{'bla'} = 1)
> >          {
> >          print "okay";
> >          }
> > else
> >         {
> >         print "not okay";
> >         }
>
> try:
>
>   if ($HASH{'bla'} == 1)
>
> hth-
> --
> Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 17 Jul 2000 01:40:00 GMT
From: mbudash@sonic.net.bbs@openbazaar.net (Michael Budash)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bQh51$XLt@openbazaar.net>

In article <Uttc5.398456$k22.1761341@flipper>, "Kliffoth" <?@?.?> wrote:

> I wrote a script to look at an array of loose words, then print "okay" if
> the word "bla" is in the array, but I just keep getting "okay" wether the
> word is in the array or not, and I just can't find out where the problem is
> :-(
>
>
> foreach $WORD (@WORD_LIST)
>          {
>          $LOW_WORD = lc $WORD;
>          $HASH{$LOW_WORD} = 1;
>          }
>
> if ($HASH{'bla'} = 1)
>          {
>          print "okay";
>          }
> else
>         {
>         print "not okay";
>         }

try:

  if ($HASH{'bla'} == 1)

hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 17 Jul 2000 03:00:10 GMT
From: aqumsieh@hyperchip.com.bbs@openbazaar.net (Ala Qumsieh)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bQj9B$Xfi@openbazaar.net>

Brian <bt@nospam.com.> writes:

> On Mon, 17 Jul 2000 01:40:04 GMT, "Kliffoth" <?@?.?> wrote:

> >if ($HASH{'bla'} = 1)

> Try if ($HASH{'bla'} == 1)
>
> You're assigning 1 to HASH{'bla'} and the 'if' is evaluating if the
> assignment worked or not.

Actually that is not exactly true. The if() is not evaluating whether
the assignment worked or not, it is evaluating the return value of the
assignment, which is the assigned value; in this case, it is one.

If you change the snippet to:

	if ($HASH{bla} = 0) {
		print "YES";
	}

The if() will evaluate to false, even though the assignment
succeeded. Of course, '-w' would warn about such a mistake.

> I can't believe I could answer a question in this forum :)

You're getting closer :)

--Ala


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

Date: 17 Jul 2000 03:20:11 GMT
From: ?@?.?.bbs@openbazaar.net (Kliffoth)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bQjYB$X5Z@openbazaar.net>

Thanx every1 who replied, even though i'm emberrased to make such a stupid
mistake. I'm using this part of the script to make an Allknowing Oracle. You
can type in any question; it looks at the string and tries to match
keywords; if it does, it generates a fitting answer. If it doesn't, it pix a
random answer like "Um, did you say something? I was playing solitaire...".
You can check it out;
http://eej.virtualave.net/orakel.html

It's Dutch though, but you can always admire the hilarious artwork a friend
of mine made ;)'


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

Date: 17 Jul 2000 10:20:02 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bR8V4$WTd@openbazaar.net>

Kliffoth wrote:

>I'm using this part of the script to make an Allknowing Oracle.
>http://eej.virtualave.net/orakel.html

It doesn't seem to know too much. The first ten questions I typed in,
all got blank answers. There isn't much fun in a oracle that fails to
produce actual replies to most questions.

You could also check out the ChatBot::Eliza module, for which Randal
Schwartz wrote a web interface for one of his Web Techniques columns.

	http://www.stonehenge.com/merlyn/WebTechniques/

see #23 and #24.

--
	Bart.


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

Date: 17 Jul 2000 11:10:02 GMT
From: ?@?.?.bbs@openbazaar.net (Kliffoth)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bR9jU$W9m@openbazaar.net>

I know Bart; the trick is, I append all the questions to a file, I'll look
at the file to see what questions are commonly asked, then I add keywords to
the code with a proper answer, making the oracle more intelligent every day
:)'

--
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/free_video/

"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:39n5nskuoq4b6s6d569j44kgkkubl3isjj@4ax.com...
> Kliffoth wrote:
>
> >I'm using this part of the script to make an Allknowing Oracle.
> >http://eej.virtualave.net/orakel.html
>
> It doesn't seem to know too much. The first ten questions I typed in,
> all got blank answers. There isn't much fun in a oracle that fails to
> produce actual replies to most questions.
>
> You could also check out the ChatBot::Eliza module, for which Randal
> Schwartz wrote a web interface for one of his Web Techniques columns.
>
> http://www.stonehenge.com/merlyn/WebTechniques/
>
> see #23 and #24.
>
> --
> Bart.


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

Date: 17 Jul 2000 19:50:04 GMT
From: lr@hpl.hp.com.bbs@openbazaar.net (Larry Rosler)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bRNNS$Wvw@openbazaar.net>

In article <g2p4nsodkvms5rbf0kpu014bkpleq9bqbb@4ax.com> on Mon, 17 Jul
2000 09:43:14 +0800, Brian <bt@nospam.com.> says...
> On Mon, 17 Jul 2000 01:40:04 GMT, "Kliffoth" <?@?.?> wrote:

 ...

> >if ($HASH{'bla'} = 1)

 ...

> Try if ($HASH{'bla'} == 1)

Or even:

      if ($HASH{bla} == 1)

Or even (because a true/false test is all that is required):

      if ($HASH{bla})

By the way, using all upper-case letters implies (by historical
convention) a constant, not a variable.

> You're assigning 1 to HASH{'bla'} and the 'if' is evaluating if the assignment
> worked or not.

Not quite -- the 'if' is evaluating the value of the assignment
expression, which is the value assigned, which is '1' (true).

> I can't believe I could answer a question in this forum :)

A more experienced answerer would have added that the use of the '-w'
flag would have pointed this error out immediately.

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


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

Date: 17 Jul 2000 22:20:02 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: [NEW-B] What's wrong with this script?
Message-Id: <3bRRJ2$V0M@openbazaar.net>

Kliffoth (?@?.?) wrote on MMDXII September MCMXCIII in
<URL:news:Uttc5.398456$k22.1761341@flipper>:
"" I wrote a script to look at an array of loose words, then print "okay" if
"" the word "bla" is in the array, but I just keep getting "okay" wether the
"" word is in the array or not, and I just can't find out where the problem is
"" :-(
""
""
"" foreach $WORD (@WORD_LIST)
""          {
""          $LOW_WORD = lc $WORD;
""          $HASH{$LOW_WORD} = 1;
""          }
""
"" if ($HASH{'bla'} = 1)
""          {
""          print "okay";
""          }
"" else
""         {
""         print "not okay";
""         }


Always, always, ALWAYS use -w!

Run your program with warnings turned on, and Perl will tell you where
you went wrong.



Abigail
--
BEGIN {$^H {join "" => ("a" .. "z") [8, 13, 19, 4, 6, 4, 17]} = sub
           {["", "Just ", "another ", "Perl ", "Hacker\n"] -> [shift]};
       $^H = hex join "" => reverse map {int ($_ / 2)} 0 .. 4}
print 1, 2, 3, 4;


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

Date: 16 Jul 2000 18:20:08 GMT
From: kloomis@bigplanet.com.bbs@openbazaar.net (Ken Loomis)
Subject: [NEWBI] Reg Exp request for help
Message-Id: <3bQVV8$W8E@openbazaar.net>

This is a multi-part message in MIME format.
--------------EFC9DE84C9CEDF61BC190116
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit

I need to take a user's input and convert it to "Proper Case".

For example:

User Input        ->         Converts to

john doe           ->         John Doe
John Doe        ->          John Doe
JOHN DOE     ->        John Doe
j q public          ->        J Q Public

123 main st       ->        123 Main St
houston             ->        Houston

I know this can be done in a regular expression, but those are so
confusing. I would appreciate any help with this.

Also, does anyone know of a book or online tutorial that does a great
job of explaining regular expressions?

Thanks,
Ken Loomis
kloomis@bigplanet.com



--------------EFC9DE84C9CEDF61BC190116
Content-Type: text/x-vcard; charset=us-ascii;
 name="kloomis.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ken Loomis
Content-Disposition: attachment;
 filename="kloomis.vcf"

begin:vcard
n:Loomis;Ken
tel;pager:888-423-8493
tel;fax:603-299-4785
tel;work:619-232-6919
x-mozilla-html:TRUE
url:http://www.KenLoomis.com/
org:Loomis Technology Group
adr:;;302 Island Avenue, Suite 201;San Diego;CA;92101;USA
version:2.1
email;internet:kloomis@bigplanet.com
title:Director
x-mozilla-cpt:;3
fn:Ken Loomis
end:vcard

--------------EFC9DE84C9CEDF61BC190116--


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

Date: 16 Jul 2000 19:00:10 GMT
From: ecco64@chello.nl.bbs@openbazaar.net (Ecco)
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <3bQWXA$V8E@openbazaar.net>

Try www.useractive.com

--
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/free_video/

"Ken Loomis" <kloomis@bigplanet.com> wrote in message
news:3971FDF6.8A4F77E0@bigplanet.com...
> I need to take a user's input and convert it to "Proper Case".
>
> For example:
>
> User Input        ->         Converts to
>
> john doe           ->         John Doe
> John Doe        ->          John Doe
> JOHN DOE     ->        John Doe
> j q public          ->        J Q Public
>
> 123 main st       ->        123 Main St
> houston             ->        Houston
>
> I know this can be done in a regular expression, but those are so
> confusing. I would appreciate any help with this.
>
> Also, does anyone know of a book or online tutorial that does a great
> job of explaining regular expressions?
>
> Thanks,
> Ken Loomis
> kloomis@bigplanet.com
>
>
>


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

Date: 16 Jul 2000 21:00:13 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <3bQZdD$Vq3@openbazaar.net>

Ken Loomis wrote:

> I need to take a user's input and convert it
> to "Proper Case".
 
> For example:
 
> User Input  ->  Converts to

> john doe    ->  John Doe
> John Doe    ->  John Doe
> JOHN DOE    ->  John Doe
> j q public  ->  J Q Public
> 123 main st ->  123 Main St
> houston     ->  Houston
 
> I know this can be done in a regular expression,
> but those are so confusing.


> I would appreciate any help with this.
 

Honestly and truly?


(snippage)



How about a nice Godzilla style schizo method?

For testing, @User_Input represents, guess?
Your user input!

First foreach prepends a space to your
user input line for a match. This is
needed because matching is based on
" space letter " style as you show.
Then all letters are lowercased.

Nested second foreach matches letters
at the beginning of each word, again
based on " space letter " matching.
Note each element in @Alpha_Up is a
space followed by a capital letter of
our English alphabet. This is where
each first letter is capitalized.

Pretty!

Last substitution line at the end of
the primary loop is to remove the
leading space prepended earlier for
a match.

All done!

Well... almost. There is another way of
doing this but it is not as much fun, sigh...


foreach $element (@User_Input)
 {
  $element = " $element";
  $element =~ tr/A-Z/a-z/;
  $element =~ s/ ([a-z])/ \u$1/g;
  $element =~ s/ //;
 }


Produces the same results, oh but is
this method ever so very boring...


Godzilla!



TEST SCRIPT:
____________

#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";


@User_Input = ("goDZilLA ROCKS!", "GOdziLLa roCks!",
               "godzilla rocks!", "GODZILLA ROCKS!");

foreach $element (@User_Input)
 {
  print "Input:  $element\n";
  $element = " $element";
  $element =~ tr/A-Z/a-z/;

  (@Alpha_Up) = (" A", " B", " C", " D", " E", " F",
                 " G", " H", " I", " J", " K", " L",
                 " M", " N", " O", " P", " Q", " R",
                 " S", " T", " U", " V", " W", " X",
                 " Y", " Z");

  foreach $au (@Alpha_Up)
    {
     if ($element =~ /($au)/i)
      { $element =~ s/$1/$au/g; }
    }

   $element =~ s/ //;
   print "Output: $element\n\n";
 }

exit;



PRINTED RESULTS:
________________

Input:  goDZilLA ROCKS!
Output: Godzilla Rocks!

Input:  GOdziLLa roCks!
Output: Godzilla Rocks!

Input:  godzilla rocks!
Output: Godzilla Rocks!

Input:  GODZILLA ROCKS!
Output: Godzilla Rocks!


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

Date: 16 Jul 2000 21:50:03 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <3bQb5R$VDX@openbazaar.net>

Avoid the words "newbie" and "help" in your subject lines --
you're more likely to get an answer if you stick to a
description of the problem.  Also, check the FAQs to see if your
question is answered there before posting.  You'll get the
answer much faster, and it will be more likely to be correct.

Ken Loomis <kloomis@bigplanet.com> wrote:

>john doe           ->         John Doe
>John Doe        ->          John Doe
>JOHN DOE     ->        John Doe
>j q public          ->        J Q Public
>123 main st       ->        123 Main St
>houston             ->        Houston
>
>I know this can be done in a regular expression, but those are so
>confusing. I would appreciate any help with this.

Type "perdoc -q capitalize" at the command line, or look in
perlfaq4 in the documentation for the question "How do I
capitalize all the words on one line?"  Note that you'll have to
give some thought to what you want to do about "John von
Neumann" and "JoAnn McDonald" (not to mention "brian d foy") --
it's not a totally soluble problem.

>Also, does anyone know of a book or online tutorial that does a great
>job of explaining regular expressions?

Look in perlre (part of the Perl documentation, which is on your
system if you've installed Perl properly).  For more than you
probably want to know about regular expressions, see "Mastering
Regular Expressions" by Jeffrey E.F. Friedl (O'Reilly).

--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)


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

Date: 16 Jul 2000 22:00:01 GMT
From: stephenk@cc.gatech.edu.bbs@openbazaar.net (Stephen Kloder)
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <3bQbI1$Szd@openbazaar.net>

Joe Kline wrote:

> [posted and mailed]
>
> Ken Loomis wrote:
>
> > I need to take a user's input and convert it to "Proper Case".
> >
> > For example:
> >
> > User Input        ->         Converts to
> >
> > john doe           ->         John Doe
> > John Doe        ->          John Doe
> > JOHN DOE     ->        John Doe
> > j q public          ->        J Q Public
> > <SNIP>
>
> Give the following a whirl:
>
> $line =~ s/(\w)(\w+)?/\u$1\L$2\E/g;
>

Not bad, but $line =~ s/(\w+)/\u\L$1/g seems prettier (probably because
it's simpler).

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.


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

Date: 18 Jul 2000 00:10:00 GMT
From: cberry@cinenet.net.bbs@openbazaar.net (Craig Berry)
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <3bRUCP$UL_@openbazaar.net>

Ken Loomis (kloomis@bigplanet.com) wrote:
: I need to take a user's input and convert it to "Proper Case".
[snip]

First, be aware that any attempt to impose case on names is doomed.  How
do you handle e.g. MacMann?  And there are a zillion other cases where
that came from.

If you really want to do this, and piss of a lot of Scots :), see the uc,
lc, ucfirst, and lcfirs functions, and their parallel \U, \L, \u, and \l
inline-string operators for use in regexes.

: Also, does anyone know of a book or online tutorial that does a great
: job of explaining regular expressions?

_Mastering Regular Expressions_ (from O'Reilly) will teach you more than
you thought existed about the subject.

--
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: 18 Jul 2000 02:50:03 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <3bRYKT$Wny@openbazaar.net>

cberry@cinenet.net (Craig Berry) wrote:

>First, be aware that any attempt to impose case on names is doomed.  How
>do you handle e.g. MacMann?  And there are a zillion other cases where
>that came from.

You put in a special case for the MacDonalds and annoy the
Macdonalds.  That's why Amazon lists an "McSe Training Kit".

--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)


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

Date: 16 Jul 2000 10:20:01 GMT
From: rootbeer&pfaq*finding*@redcat.com.bbs@openbazaar.net (Tom Phoenix)
Subject: [Perl] How to find the Perl FAQ
Message-Id: <3bQJ71$THe@openbazaar.net>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

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


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

Date: Tue, 18 Jul 2000 13:56:33 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: accessing perldoc without having to telnet?
Message-Id: <8l1h18$cvt$12$1@news.t-online.com>

Hi,

Is there a way of accessing the perldoc without having to telnet? What do I
have to install/download?

Thanks!

Raphael




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

Date: Tue, 18 Jul 2000 14:13:38 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: accessing perldoc without having to telnet?
Message-Id: <8l1hvg$db1$12$1@news.t-online.com>

just found out how to do it: Install ActivePerl and then click "Start" |
"Run" and then you can enter perldoc! Cool!!!! :-)




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

Date: 16 Jul 2000 19:40:10 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: Accessing string
Message-Id: <3bQXZA$VyN@openbazaar.net>

martho@my-deja.com wrote:

>Are there any possebilitys to access a string like in other
>script-languages with
>left
>right
>mid

substr, for all three

>length

Guess...

--
	Bart.


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

Date: 18 Jul 2000 00:00:01 GMT
From: kuzmin@hotmail.com.bbs@openbazaar.net (Oleg Kuzmin)
Subject: Active State Perl on IIS 4.0
Message-Id: <3bRU01$Tfa@openbazaar.net>

Greetings!

I'm trying to make Active State Perl work on IIS 4.0 to be able to create
server-side scripts in Perl, not only in JavaScript or VBScript.  I couldn't
make it run successfully on my web server yet.  Is there a site with good
instructions on how to set it up?

Thanks,


Oleg


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

Date: 18 Jul 2000 01:50:02 GMT
From: RichardWoodward@hotmail.com.bbs@openbazaar.net ()
Subject: Re: Active State Perl on IIS 4.0
Message-Id: <3bRWfQ$WLr@openbazaar.net>

Hello, Oleg.

If you have installed ActivePerl in a standard way and
asked for the html documentation, you should be able
to use your Windows Explorer and double click on
the file below (assuming you used c:\Perl as the
root of your perl package)--

C:\Perl\html\faq\Windows\ActivePerl-Winfaq6.html

There is some information there specific to IIS 4.

If you get stuck, send me private email detailing your
problem and I'll help if I can.

Regards,
Richard Martin Woodward
RichardWoodward@hotmail.com
=====================================


> I'm trying to make Active State Perl work on IIS 4.0 to be able to
> create server-side scripts in Perl, not only in JavaScript
> or VBScript.  I couldn't make it run successfully on my web
> server yet.  Is there a site with good
> instructions on how to set it up?
>
> Thanks,
> Oleg


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


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

Date: 13 Jul 2000 22:00:02 GMT
From: archulee@pebio.com.bbs@openbazaar.net (Eric Archuleta)
Subject: Re: Activestate PPM not working for Windows?
Message-Id: <3bOKg3$XHY@openbazaar.net>

You may be able to download a ppd file for that module and run ppm locally.
Here is a link to some zipped up module ppd's

http://www.ActiveState.com/ppmpackages/5.005/zips

I had NO luck trying to build any modules myself. Also the latest version
of Perl from ActiveSate is a bit flakey. You may want to use an older
version. That is what I had to do after a week of struggleing with the new
version.

Good Luck
Eric

Jerry Leventer wrote:

> I have also had problems with the ActiveState PPM on Windows NT4 & 95.
> I tried,
>
>        ppm> search Net::SMTP
>   and, ppm> install Net::SMTP
>
> but, module could not be found (no error msg just blank line with
> prompt).  Looks like I'll have to download the Net:SMTP module from
> ActiveState & use makefiles to build it.
>
> In article <3964EE89.ADAE143F@in.tum.de>,
>   Gerhard Popp <popp@in.tum.de> wrote:
> > Hello,
> >
> > I downloaded a up to date version of perl from www.activate.com.
> > Furtermore I downloaded some Modules, e.g DBI.zip, Win32-ODBC.zip,...
> > After I had extracted the zip-files, I wanted to install the
> ppd-modules.
> >
> > Now my problem:
> > How could I install this module packages with my Perl Packet Manager
> > unter WinNT bzw. Win2000?
> > If I start the ppm with e.g.
> >
> >     ppm install Win32-ODBC.ppd
> >     (Win32-ODBC is in the current directory)
> >
> > I got the following error-message:
> >
> >     Error installing package 'Win32-ODBC.ppd': Could not locate a PPM
> >     binary of Win32-ODBC.ppd for this platform.
> >
> > I know, there are several binary for different platforms, but
> Win32-ODBC
> > doesn't work under NT4.0 or Win2000 too.
> >
> > Knows anybody a solution for this problem or a server, where I could
> get
> > a other perl-distribution, which is complete or easier to install?
> >
> > Greetings,
> >     Gerhard
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: 13 Jul 2000 22:30:03 GMT
From: nathan.wiger@west.sun.com.bbs@openbazaar.net (Nathan Wiger)
Subject: Advanced Regexp Parsing HELP! Please
Message-Id: <3bOLVR$Xq9@openbazaar.net>

Hi all-

I'm working on a project which has to parse an Apache-like configuration
file. The file it needs to parse will have lines that look like this:

   SomeVariable     /path/name
   SomeArray        index.html index.shtml index.cgi
   SomeScalar       "with spaces in it"
   SomethingTough   mixed array "where some" have "spaces "

Give this example file, it would then have to set the following hash
reference:

   $config->{somevariable}   = "/path/name";
   $config->{somearray}      = [ index.html, index.shtml, index.cgi ];
   $config->{somescalar}     = "with spaces in it";
   $config->{somethingtough} =
          [ mixed, array, "where some", have, "spaces " ];

So, double quotes are used to distinguish between scalars and arrays,
consistent with Apache and many other config files. The design has to be
flexible enough to handle all the cases above.

I'm 98% of the way there. I'm doing this with regular expression pattern
matches, which is the most efficient way I've found of doing it. The
code is actually really compact:

   # [ ... ] each line of the file is in $_
   ($key) = (m#^(\w+)(?=\s+)#g);              # split up key
   (@val) = (m#\s+(?:"([^"]*)"|(\S+))\n?#g);  # split up val


The regexp should theoretically look for quoted strings and keep them
together, or grab everything that's non-whitespace and keep that
together, thus differentiating on the fly. It seems to work pretty well.

The only problem I'm having is that this ends up inserting blank
elements in the @val array in the following pattern:

   1. after strings with quotes in them
   2. before strings without quotes

So, for example:

   SomeQuoted    "quoted"

Actually gives you:

   $val[0] = "quoted"
   $val[1] = ""

And:

   SomePlainText  unquoted

Gives you:

   $val[0] = ""
   $val[1] = "unquoted"

This is consistent even on mixed values, so:

   SomeMixed   "quoted" unquoted

Gives you:

   $val[0] = "quoted"
   $val[1] = ""
   $val[2] = ""
   $val[3] = "unquoted"

There has GOT to be something fundamental I'm missing here. I've looked
that the regexp I'm using for the @val parsing over and over and still
can't figure out what's wrong with it. Help please!!

Thanks,
Nate


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

Date: 13 Jul 2000 23:10:02 GMT
From: andrew-johnson@home.com.bbs@openbazaar.net (Andrew Johnson)
Subject: Re: Advanced Regexp Parsing HELP! Please
Message-Id: <3bOMXR$WHu@openbazaar.net>

In article <396E3A2E.9D25ECEE@west.sun.com>,
 Nathan Wiger <nathan.wiger@west.sun.com> wrote:
> Hi all-
>
> I'm working on a project which has to parse an Apache-like configuration
> file. The file it needs to parse will have lines that look like this:
>
>    SomeVariable     /path/name
>    SomeArray        index.html index.shtml index.cgi
>    SomeScalar       "with spaces in it"
>    SomethingTough   mixed array "where some" have "spaces "
>
> Give this example file, it would then have to set the following hash
> reference:
>
>    $config->{somevariable}   = "/path/name";
>    $config->{somearray}      = [ index.html, index.shtml, index.cgi ];
>    $config->{somescalar}     = "with spaces in it";
>    $config->{somethingtough} =
>           [ mixed, array, "where some", have, "spaces " ];
>
> So, double quotes are used to distinguish between scalars and arrays,
> consistent with Apache and many other config files. The design has to be
> flexible enough to handle all the cases above.
>
> I'm 98% of the way there. I'm doing this with regular expression pattern

Without answering your direct question exactly, you could use
a module like Text::ParseWords to achieve your goal. You'd likely
want to provide more validation, avoid blank lines and comments, etc,
but the following might give you something you can work from:

#!/usr/bin/perl -w
use strict;
use Text::ParseWords;

my $config;
while(<DATA>){
    chomp;
    my @parsed = parse_line('\s+',0,$_);
    if(@parsed == 2) {
        $config->{$parsed[0]} = $parsed[1];
    } elsif (@parsed > 2) {
        $config->{$parsed[0]} = [ @parsed[1..$#parsed] ];
    } else {
        warn "problem with line: $.";
    }
}

foreach my $key (keys %$config){
    if( ref $config->{$key} ){
        print "$key : ", map("<$_>", @{$config->{$key}}), "\n";
    } else {
        print "$key : <$config->{$key}>\n";
    }
}

__DATA__
SomeVariable     /path/name
SomeArray        index.html index.shtml index.cgi
SomeScalar       "with spaces in it"
SomethingTough   mixed array "where some" have "spaces "


This prints:
SomeScalar : <with spaces in it>
SomeVariable : </path/name>
SomethingTough : <mixed><array><where some><have><spaces >
SomeArray : <index.html><index.shtml><index.cgi>

Just a thought.
regards,
andrew

--
Andrew L. Johnson   http://members.home.net/perl-epwp/
      Optimist:  The glass is half full.
      Pessimist: The glass is half empty.
      Engineer:  The glass is twice as big as it needs to be.


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

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


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