[17796] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5216 Volume: 9

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

Date: Thu, 28 Dec 2000 21:05:13 -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: <978066312-v9-i5216@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 28 Dec 2000     Volume: 9 Number: 5216

Today's topics:
    Re: A question on pattern matching. <chmod007@hotmail.com>
    Re: A question on pattern matching. <mbudash@sonic.net>
        big projects smittod@auburn.edu
    Re: big projects (Tad McClellan)
        BINDING <rucus20@hotmail.com>
        Can someone explain operator association *better*? <goose@enteract.com>
    Re: Can someone explain operator association *better*? <mischief@velma.motion.net>
    Re: Code Review? (Garry Williams)
    Re: Code Review? (Colin Watson)
    Re: Create time <tony_curtis32@yahoo.com>
    Re: Extract the nth word from a line <johnlin@chttl.com.tw>
    Re: Extract the nth word from a line <rick.delaney@home.com>
    Re: FAQ 6.21:   What's wrong with using grep or map in  <johnlin@chttl.com.tw>
    Re: flat file database question <bwalton@rochester.rr.com>
    Re: Free win32 Perl IDE+easiest way to start learning P <bart.lateur@skynet.be>
    Re: Free win32 Perl IDE+easiest way to start learning P (Homer Simpson)
        Friends, where is the FAQ? <jeremyk.remove-this@privacy.nu>
    Re: Friends, where is the FAQ? <lmm713@neosoft.com>
    Re: Friends, where is the FAQ? <jeremyk.remove-this@privacy.nu>
    Re: Help with searching flat files & CGI wendywds@my-deja.com
        How do I read a block from a file? nodo70@my-deja.com
    Re: How do I read a block from a file? <bwalton@rochester.rr.com>
    Re: HTTPS using LWP but no OpenSSL <mbudash@sonic.net>
    Re: Loop is wrong (oh and it won't compile) (Tad McClellan)
    Re: Need help changing wrapped line to non-wrapped. (Tad McClellan)
        Newbie with Session Key and META questions <markymoon@zenbydesign.com>
    Re: Piping output from one script into another <nospam@nospam.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 29 Dec 2000 00:48:50 -0000
From: chmod007 <chmod007@hotmail.com>
Subject: Re: A question on pattern matching.
Message-Id: <t4nnriiajlg2c4@corp.supernews.com>


koppum wrote:
> 
> 
> Hi,
> 
> I have the following problem when I try to match a string.
> 
> example:
> 
> $str1 = 'ABC$XYZ';
> $str2 = 'C$X'
> 
> Now I like to detect (and may be make a substitution) the above
> condition that $str1 contains $str2, like say:
> 
> if ($str1 =~ /$str2/) {....
> 
> The problem is that whenever there are characters like '$' perl treats
> it as a character with special meaning (end of line).
> 
> Now, is there a modifier or something that I can do to let perl know
> that I want to turn-off that special meaning for those characters like
> $. I consulted several books (programming perl, cookbook etc.) but
> without any success.
> 
> Any help is highly appreciated.
> Thanks in advance.
> Murali
> 
> 
> Sent via Deja.com
> http://www.deja.com/


I gather since you don't have double quotes around your $str1 and $str2 
the $X is not being evaluated.  So for you matching string $str2 just 
escape the $.

so:
 $str1 = 'ABC$XYZ';
 $str2 = 'C\$X'

 if ($str1 =~ /$str2/) {....

will work.


--
Posted via CNET Help.com
http://www.help.com/


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

Date: Thu, 28 Dec 2000 17:29:39 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: A question on pattern matching.
Message-Id: <mbudash-C84A52.17293928122000@news.pacbell.net>

In article <t4nnriiajlg2c4@corp.supernews.com>, chmod007 
<chmod007@hotmail.com> wrote:

> koppum wrote:
> > 
> > 
> > Hi,
> > 
> > I have the following problem when I try to match a string.
> > 
> > example:
> > 
> > $str1 = 'ABC$XYZ';
> > $str2 = 'C$X'
> > 
> > Now I like to detect (and may be make a substitution) the above
> > condition that $str1 contains $str2, like say:
> > 
> > if ($str1 =~ /$str2/) {....
> > 
> > The problem is that whenever there are characters like '$' perl treats
> > it as a character with special meaning (end of line).
> > 
> > Now, is there a modifier or something that I can do to let perl know
> > that I want to turn-off that special meaning for those characters like
> > $. I consulted several books (programming perl, cookbook etc.) but
> > without any success.
> > 
> > Any help is highly appreciated.
> > Thanks in advance.
> > Murali
> > 
> > 
> > Sent via Deja.com
> > http://www.deja.com/
> 
> 
> I gather since you don't have double quotes around your $str1 and $str2 
> the $X is not being evaluated.  So for you matching string $str2 just 
> escape the $.
> 
> so:
>  $str1 = 'ABC$XYZ';
>  $str2 = 'C\$X'
> 
>  if ($str1 =~ /$str2/) {....
> 
> will work.
> 

so will:

if ($str1 =~ /\Q$str2/) {....

(see the section on 'escape' in the camel book...)
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Thu, 28 Dec 2000 23:07:34 GMT
From: smittod@auburn.edu
Subject: big projects
Message-Id: <92gh3j$4l9$1@nnrp1.deja.com>

I've been programming perl for 4 years, and I'm just not very good a
organizing big projects. I can write code and subroutines and normal
sized programs with the best of 'em, but I can't get organized when it
comes to big projects. Is there a book i can read or something that
will teach me how to put together a huge programming project, like an e-
commerce site with a big backend database?


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


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

Date: Thu, 28 Dec 2000 20:07:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: big projects
Message-Id: <slrn94noub.hcq.tadmc@magna.metronet.com>

smittod@auburn.edu <smittod@auburn.edu> wrote:
>I'm just not very good a
>organizing big projects.

>I can't get organized when it
>comes to big projects. Is there a book i can read or something that
>will teach me how to put together a huge programming project, like an e-
>commerce site with a big backend database?


You need a healthy dose of Software Engineering including
analysis and design.

The best place to find out about Software Engineering is
in the Software Engineering newsgroup :-)

   comp.software-eng

Do a Dejanews search, and check their FAQ first (if any)
before posting.


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


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

Date: Thu, 28 Dec 2000 22:02:59 -0800
From: "Rucus20" <rucus20@hotmail.com>
Subject: BINDING
Message-Id: <t4nvugcu4fma91@corp.supernews.com>

Can I bind a client to a port on my server.
say i have a user "ClientA" that wants to share my files on
localhost:80/
I want the client to be localhost:81/
get it
it has to be a perl script;

AGENT X
rucus20@hotmail.com





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

Date: Thu, 28 Dec 2000 17:45:37 -0600
From: Jerome Mrozak <goose@enteract.com>
Subject: Can someone explain operator association *better*?
Message-Id: <3A4BD0A1.5008438C@enteract.com>

All these years and I've sort-of faked it with operator association. 
But the book has me scratching my head and vowing I'll have to read it
until it makes sense.  
 
For example, _Programming_Perl_ (3rd edition) Chapter 3 deals with terms
and operators and describes which looks leftward, and I'm thinking "what
looks left to find what?  Left to find its owner?  Right to determine
which of identical terms go first?"

Most code is subdivided simply enough to grok the term order, but I want
to understand through use of technical language, rather than just the
usage in practice.

TIA,
Jerome.
-- 
Jerome Mrozak          "Never buy a dog and bark for yourself"
goose@enteract.com     --"Slippery" Jim DiGriz
                         (the Stainless Steel Rat)


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

Date: Fri, 29 Dec 2000 03:13:41 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Can someone explain operator association *better*?
Message-Id: <t4o0b5gmdh2se2@corp.supernews.com>

Jerome Mrozak <goose@enteract.com> wrote:
> All these years and I've sort-of faked it with operator association. 
> But the book has me scratching my head and vowing I'll have to read it
> until it makes sense.  

Associativity and precedence are related topics. Both are topics well-covered
in compiler design texts. They are probably well-covered in mathematical
theory as well, but that's not my area.

If you really want to learn about operator associativity, read something
about parsing. I'd suggest "Lex and Yacc" by Levine, Mason, and Brown
( published by O'Reilly, ISBN: 1565920007 ) for this. If you really, 
really want to get into operator associativity, there may be even better
places to look. You could go overboard looking at full-blown compiler texts.
As I mentioned before, there's  probably something in some math theory books,
but I come to programming from a more linguistic than mathematical background
(perhaps that's why I like Perl so much). 

>  
> For example, _Programming_Perl_ (3rd edition) Chapter 3 deals with terms
> and operators and describes which looks leftward, and I'm thinking "what
> looks left to find what?  Left to find its owner?  Right to determine
> which of identical terms go first?"

The operator itself is bound to the terms. An operator can be bound to the
term to its left, the term to its right, or to both terms equally. This
last scenario gives what is called a 'binary operator', since it always
has two arguments.

A language which allows compound expressions and/or multiple expressions per
statement has to also either have a well-defined parse order (left-to-right
or right-to-left) or have some ambiguity as to how the operators are bound to
expressions. I believe that Perl parses left to right, but i could be mistaken.


When in doubt, parenthesize.

> Most code is subdivided simply enough to grok the term order, but I want
> to understand through use of technical language, rather than just the
> usage in practice.

When in doubt, parenthesize.

There's an old adage my math instructors always told me about precedence
and associativity. It goes like this: When in doubt, parenthesize.


Chris
-- 
Christopher E. Stith

Wbere there's a will, there's a lawyer.



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

Date: Thu, 28 Dec 2000 23:24:41 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Code Review?
Message-Id: <ZYP26.210$ld.20326@eagle.america.net>

On 28 Dec 2000 20:45:42 GMT, David H. Adler <dha@panix2.panix.com> wrote:
>>Garry Williams <garry@zvolve.com> wrote:
>>>On 28 Dec 2000 02:02:52 GMT, Colin Watson <cjw44@flatline.org.uk> wrote:
>>>>Style nit: no need to quote hash keys if they're just words.
>>>
>>>Hmmm.  I wonder if that's good advice?  
>>>
>>>  $ perl -wle '$x{"time"} = "Hello, world";print $x{time}'
>>>  Ambiguous use of {time} resolved to {"time"} at -e line 1.
>>>  Hello, world
>>>  $ perl -v
>>>
>>>  This is perl, version 5.004_04 built for sun4-solaris

[snip]

>To muddy the waters even further, from perldata:
>
>       As in some shells, you can put curly brackets around the
>       name to delimit it from following alphanumerics.  In fact,
>       an identifier within such curlies is forced to be a
>       string, as is any single identifier within a hash sub-
>       script.  Our earlier example,
>
>           $days{'Feb'}
>
>       can be written as
>
>           $days{Feb}
>
>       and the quotes will be assumed automatically.  But any-
>       thing more complicated in the subscript will be inter-
>       preted as an expression.
>
>So there *is* some backup from the docs for thinking that $hash{time}
>would be the same as $hash{'time'}.

So, 5.004_04 has a bug.  (That assumes that the doc is correct since
it seems to have been fixed since then.)  

-- 
Garry Williams


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

Date: 29 Dec 2000 02:34:15 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: Code Review?
Message-Id: <92gt77$bcd$1@riva.ucam.org>

Garry Williams <garry@zvolve.com> wrote:
>On 28 Dec 2000 20:45:42 GMT, David H. Adler <dha@panix2.panix.com> wrote:
>>>Garry Williams <garry@zvolve.com> wrote:
>>>>  $ perl -wle '$x{"time"} = "Hello, world";print $x{time}'
>>>>  Ambiguous use of {time} resolved to {"time"} at -e line 1.
>>>>  Hello, world
>>>>  $ perl -v
>>>>
>>>>  This is perl, version 5.004_04 built for sun4-solaris
>
>[snip]
>
>>So there *is* some backup from the docs for thinking that $hash{time}
>>would be the same as $hash{'time'}.
>
>So, 5.004_04 has a bug.  (That assumes that the doc is correct since
>it seems to have been fixed since then.)  

At a guess, it looks like this change in 5.004_05:

  Change 661 on 1998/03/03 by TimBunce@ig.co.uk

       Title:  "Don't warn on $x{shift}, ne => 1, or -f => 1", #F028
        From:  Chip Salzenberg
       Files:  toke.c

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"We reject: kings, presidents, and voting.
 We believe in: rough consensus and running code."
  - Dave Clark, IETF, 1992


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

Date: 28 Dec 2000 17:11:46 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Create time
Message-Id: <877l4k6szx.fsf@limey.hpcc.uh.edu>

>> On Thu, 28 Dec 2000 22:49:24 GMT,
>> Mikey N <grillboy6000@my-deja.com> said:

> I'm a newbie Perl programmer and I'm having a tough time with time
> functions.  Is there any way to create a time object with a date in
> this format: 'yyyy-mm-dd'?

perldoc POSIX, see strftime().

> '2000-12-25'.  I would like to be able to use this format to create
> a string that says: "The data for Monday, Dec. 25th is ..."

Date::Manip and Date::Calc could be useful here.  Also Time::Local
might help.

> Mike Nass(grillboy6000) miken@backtothebible.org

Nah, let's go forward!

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Fri, 29 Dec 2000 08:37:24 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Extract the nth word from a line
Message-Id: <92gmg3$p9p@netnews.hinet.net>

"Roger Hinson" wrote
> I grabbed this out of the Perl FAQ..
>
> How do I change the Nth occurrence of something?
>
> In the more general case, you can use the /g modifier in a while loop,
> keeping count of matches.
>
>     $WANT = 3;
>     $count = 0;
>     while (/(\w+)\s+fish\b/gi) {
>         if (++$count == $WANT) {
>             print "The third fish is a $1 one.\n";
>             # Warning: don't `last' out of this loop
>         }
>     }

>             # Warning: don't `last' out of this loop

I did some experiments.  There was nothing wrong to 'last' out of a
while loop with /g modifier.  It's OK, isn't it?

John Lin





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

Date: Fri, 29 Dec 2000 02:46:45 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Extract the nth word from a line
Message-Id: <3A4BFEB5.4B4B1AF3@home.com>


John Lin wrote:
> 
> "Roger Hinson" wrote
> >
> >     $WANT = 3;
> >     $count = 0;
> >     while (/(\w+)\s+fish\b/gi) {
> >         if (++$count == $WANT) {
> >             print "The third fish is a $1 one.\n";
> >             # Warning: don't `last' out of this loop
> >         }
> >     }
> 
> >             # Warning: don't `last' out of this loop
> 
> I did some experiments.  There was nothing wrong to 'last' out of a
> while loop with /g modifier.  It's OK, isn't it?

Is is OK.  The warning is useless without an explanation.

I have no idea what Roger means so I'm just going to point out stuff
that comes to mind.  Writing the code like this would be wrong:

    while (/(\w+)\s+fish\b/gi) {
        if (++$count == $WANT) {
            last;
        }
    }
    print "The third fish is a $1 one.\n";

This is because $1 is localized to within the while loop so is not what
you want outside the loop.  It has nothing to do with last.

If last is used to exit the loop then pos is not reset.  This is
something to be aware of but is not necessarily a reason to avoid last.
It may even be what you want.

    while (/(\w+)\s+fish\b/gi) {
        if (++$count == $WANT) {
            print "The third fish is a $1 one.\n";
            last;
        }
    }
    if (/(\w+)\s+fish\b/g) {
        print "The next fish is a $1 one.\n";
    }


-- 
Rick Delaney
rick.delaney@home.com


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

Date: Fri, 29 Dec 2000 09:14:36 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: FAQ 6.21:   What's wrong with using grep or map in a void context?
Message-Id: <92gon1$rsf@netnews.hinet.net>

"Bart Lateur" wrote:

> map() and grep() are not loops. They do something to each item, but
> theoretically there's no garantee that it will be in the "natural"
> order. Execution order might just as well be shuffled.

I doubt that.  If the execution order is not defined, the operation would
have different possible results, which is difficult to use.

grep /^b/,'good','better','best';
could returns
('better','best') or ('best','better')

map {$_? ('a','b'): 'c'} 0,1;
could returns
('c','a','b') or ('a','b','c')

Hmm...  If we treat grep(), map() as 'set' to 'set' mapping, it would be
fine.
But Perl doesn't have 'set' variables.  They apply to 'array's, right?

John Lin





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

Date: Fri, 29 Dec 2000 02:45:31 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: flat file database question
Message-Id: <3A4BFBE1.721B39DB@rochester.rr.com>

"Adam C. Mihlfried" wrote:
> 
> I was wondering if anyone has come across a good program that handles
> flatfile databases through perl. More specifically one that can handle a
> directory-like structure with category->subcategory->record information.
 ...
> Adam
> adamm@stargate.net
Check out the DBI and DBD::CSV modules.  Those will let you do what you
want, using SQL to yak with your flat files, one file per table.  You
should be able to do most anything you can do with a "real" database
(but a bit less efficiently, perhaps).  Your mileage might vary with
this if your platform is Windoze 9x.
-- 
Bob Walton


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

Date: Fri, 29 Dec 2000 00:09:54 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Free win32 Perl IDE+easiest way to start learning Perl
Message-Id: <7jln4tghug0r3hrvn8h3ehdjvnpknpn3r3@4ax.com>

Joe Schaefer wrote:

>Any reason a cross-platform editor like emacs didn't make your list?
>
>http://www.emacs.org

Because I don't like it? And vi either? At all?

-- 
	Bart.


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

Date: 29 Dec 2000 02:17:04 GMT
From: homer.simpson@springfield.nul (Homer Simpson)
Subject: Re: Free win32 Perl IDE+easiest way to start learning Perl
Message-Id: <92gs70$5js$0@216.39.130.68>

In article <HqF26.4761$3U5.5035@nntpserver.swip.net>, "Samuel Rydén" <samuel@knm-e.se> wrote:
>> As for learning perl: I'd get a decent text editor, one that can run
>> "external tools", and capture their outputs (STDOUT and STDERR) in
>> another window. In that case, you can edit a perl script, click on the
>> "run" menu item or button, and you almost immediately see the result in
>> a new editor window. No need for a specific Perl IDE, a decent general
>> "programmer editor" will do.
>
>Do you perhaps have one to recommend?
>
>
>- Samuel
>
>
VIM
http://www.vim.org/

An IMproved version of vi.

Once you learn a few simple keyboard commands you'll be able to edit code, 
shell to the os to run it, read in other files to include source and more 
without ever taking your hands off of the keyboard.

VERY programmable and Perl and many other languages are supported with syntax 
highlighting.  It's the only "IDE" a real Perl Hacker needs and once you learn 
it you can edit Perl on any Unix platform as well as on Win32 and BEOS.


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

Date: Thu, 28 Dec 2000 18:56:16 -0500
From: Jeremy <jeremyk.remove-this@privacy.nu>
Subject: Friends, where is the FAQ?
Message-Id: <3A4BD320.A5C8E31C@privacy.nu>

Friends, 
where can I find the FAQ for this ng? Or, perhaps you can tell me
directly, where do I get NT-version of perl (and, hopefully, os-specific
docs for it.)

Thanks.
Jeremy


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

Date: Thu, 28 Dec 2000 19:30:10 -0600
From: "Louis Miller" <lmm713@neosoft.com>
Subject: Re: Friends, where is the FAQ?
Message-Id: <11B2FB6F5A8BAAE0.41A06AE5B87765C6.B6C94B2EF6DF03BD@lp.airnews.net>

NT Version and FAQ located at:
www.activestate.com

Jeremy <jeremyk.remove-this@privacy.nu> wrote in message
news:3A4BD320.A5C8E31C@privacy.nu...
> Friends,
> where can I find the FAQ for this ng? Or, perhaps you can tell me
> directly, where do I get NT-version of perl (and, hopefully, os-specific
> docs for it.)
>
> Thanks.
> Jeremy




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

Date: Thu, 28 Dec 2000 20:43:18 -0500
From: Jeremy <jeremyk.remove-this@privacy.nu>
Subject: Re: Friends, where is the FAQ?
Message-Id: <3A4BEC36.4E53D60F@privacy.nu>

Louis Miller wrote:
> 
> NT Version and FAQ located at:
> www.activestate.com
Thank you!

> 
> Jeremy <jeremyk.remove-this@privacy.nu> wrote in message
> news:3A4BD320.A5C8E31C@privacy.nu...
> > Friends,
> > where can I find the FAQ for this ng? Or, perhaps you can tell me
> > directly, where do I get NT-version of perl (and, hopefully, os-specific
> > docs for it.)
> >
> > Thanks.
> > Jeremy


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

Date: Fri, 29 Dec 2000 01:49:53 GMT
From: wendywds@my-deja.com
Subject: Re: Help with searching flat files & CGI
Message-Id: <92gqjv$c0f$1@nnrp1.deja.com>

wendywds@my-deja.com wrote:
> So here I sit in my cgi-bin directory, trying to get chdir() to work
> and change me to my /photos/ directory.

Sorry to follow up on myself, but I hate doing deja searches and
finding a question but no answer...

When a script is running on Tripod, it thinks cgi-bin is the root
directory.  You can't go up any further than that.  (Which means... you
can't write a search engine unless you put your entire site below cgi-
bin???)  So no wonder I couldn't chdir() anywhere else.

Having moved my data files below cgi-bin, it's working now!  Thanks
again.  I'll be back with a _real_ Perl question next time.

Wendy


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


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

Date: Fri, 29 Dec 2000 01:57:10 GMT
From: nodo70@my-deja.com
Subject: How do I read a block from a file?
Message-Id: <92gr1k$cdn$1@nnrp1.deja.com>

If I have a file call data.txt containing something like this:
path = "/animal/dog/";
allow (all)
  (group = "admin");
allow absolute (all)
  (group = "dog");

path = "/animal/bird/";
allow (all)
  (group = "gatekeeper");
allow absolute (all)
  (group = "bird");

 .....
and so on

How do I read certain block if I want to read from path that have bird
til group bird?  In other word, I want to read a block randomly.  Your
help is greatly appreciate.

Thanks,
noDo


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


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

Date: Fri, 29 Dec 2000 03:13:57 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How do I read a block from a file?
Message-Id: <3A4C028B.8DB34571@rochester.rr.com>

nodo70@my-deja.com wrote:
> 
> If I have a file call data.txt containing something like this:
> path = "/animal/dog/";
> allow (all)
>   (group = "admin");
> allow absolute (all)
>   (group = "dog");
> 
> path = "/animal/bird/";
> allow (all)
>   (group = "gatekeeper");
> allow absolute (all)
>   (group = "bird");
> 
> .....
> and so on
> 
> How do I read certain block if I want to read from path that have bird
> til group bird?  In other word, I want to read a block randomly.  Your
> help is greatly appreciate.
> 
> Thanks,
> noDo
 ...
A hash is tailor-made to store things you want to look up ""randomly"
using a key.  If your data will fit in memory, just read it all into a
hash and go.  If it won't fit in memory, use a tied hash (then you only
have to do the conversion to a hash once; after that, you can just use
the resulting DBM-type file that got created).  Something like:

    $/='';
    while(<DATA>){
        next unless m#/(\w+)/"#;
        $hash{$1}=$_;
    }
    #use hash to look up by keys like dog or bird
    __DATA__
    path = "/animal/dog/";
    allow (all)
      (group = "admin");
    allow absolute (all)
      (group = "dog");
    
    path = "/animal/bird/";
    allow (all)
      (group = "gatekeeper");
    allow absolute (all)
      (group = "bird");

if I grokked your description right.
-- 
Bob Walton


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

Date: Thu, 28 Dec 2000 17:35:21 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: HTTPS using LWP but no OpenSSL
Message-Id: <mbudash-2D3A46.17352128122000@news.pacbell.net>

In article <3a4bc482$0$57179$272ea4a1@news.execpc.com>, 
newsgroup@nathigh.com (Scott Zsori) wrote:

> How do you perform a HTTPS GET?  I know the standard response of LWP with 
> OpenSSL and Net::SSLeay, but I don't have access to OpenSSL or Net:SSLeay 
> on the server.  Any help would be appreciated.

'the standard response' does not imply any direct access to either 
OpenSSL or Net:SSLeay. if ssl support is correctly installed on the 
server, you should be able to use lwp for ssl connections transparently. 
remember to be aware of connections thru proxies (see lwpcook.pod) ...

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


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

Date: Thu, 28 Dec 2000 17:27:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Loop is wrong (oh and it won't compile)
Message-Id: <slrn94nfib.h33.tadmc@magna.metronet.com>

Lou Moran <lmoran@wtsg.com> wrote:

>The one thing I sort of dislike about Perl is when it tells me a line
>number I believe it.  I find a lot of times that the problem is a line
>or two above the line (like a missing semi colon or something.  I
>still use -w but think it's weird that it says the problem is one
>place and it's really somewhere else.


You have the same problem with all programming languages then! 
Nothing Perl-specific about that.

It is a parsing theory problem (error reporting/recovery is "hard").


It is kind of like when you are following directions to some
place you have never been to before.

At some point you realize "I'm lost", but you don't know where
you made the wrong turn. All you (and the compiler) can do
is admit it as soon as you _notice_ that you are lost. Can't
do much about indicating where before here you actually went wrong.


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


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

Date: Thu, 28 Dec 2000 19:27:50 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help changing wrapped line to non-wrapped.
Message-Id: <slrn94nmk6.h33.tadmc@magna.metronet.com>

Roger Hinson <hinson@home.com> wrote:

[ snip "wants to join continuation lines" ]

>server.backup.somewhere.com:servername
>                        9  12/24/00 12:01:42   0:25:45 Completed       
>951\      0   48.4 MB Complete
>server.backup.somewhere.com:server
>                        9  12/24/00 13:01:27   0:12:58 Completed       
>173\      0  303.3 MB Complete

>#!c:/perl

   #!c:/perl -w
   use strict;

Adding those two things are asking perl to help you find common
mistakes. Take all of the help that you can get. Always use both.


># Open the daily log
>
>$TESTFILE="c:/roger/perl/12242000.txt";

You are using sane slashes. Very good move!

   my $testfile = "c:/roger/perl/12242000.txt";


UPPERCASE names are yucky.

my() to make "use strict" happy.

Use whitespace to make your code easier to read.


>open FILEHANDLE, $TESTFILE;

You should always, yes *always*, check the return value from open:

   open INFILE, $testfile or die "could not open '$testfile'  $!";
                                                                ^^

Be sure to include the $! special variable in the diagnostic message.

You have named your filehandle "FILEHANDLE". That isn't a very helpful
choice of names. Imagine a dog named Dog  :-)

The hardest, most "expensive" part of programming is "maintenance", 
i.e. fixing bugs and adding new features.

It is Very Good Practice to drop some "bread crumbs" behind you
as you write the program so that you can more easily find your
way when you find yourself back here after being away for a
few weeks or months.

Choose a name that will help you remember what you were using it for.


>open OUT, ">$OUTFILE";


Even IN would have been a better filehandle than FILEHANDLE.

Check the return value here too.


>while (<FILEHANDLE>)	{
>	tr/\012/#/;            #remove the new line and replace with a #
>	s/#        / /ig;      #if the resulting line has spaces after # take


You shouldn't throw options on the end willy nilly. If you don't
know what they do, then do not use them. If you think you need to
use them, then find out what they do (perldoc perlop).

s///i ignores case, but you do not even have any letters in your
pattern! The 'i' can have no effect, so it should not be there.


>them out
>	tr/#/\012/;            #replace the remaining #'s with new lines


You do not need the insert flag/subst/remove flag sequence. You
can just write a s/// that does the right thing straightaway:

   s/\n        / /g;  # would work if we had multiple lines in $_ ...


>	print OUT;             #write the file
>	}
>
>	I've tried the script and it writes the file just as it was when I
>started.  I'm doing something wrong with the substitution


No you're not.

Your problem is that you never have more than one line at a time
in $_, the <INPUT_OPERATOR> reads _a_ (one) line at a time.

$_ will always _end_ with a newline character, there can
never be space characters after it.


If you want to work on multiline strings, your first task is to
_get_ multiline strings to work on  :-)

An expedient way, if the file isn't "too big", would be to slurp 
the whole file into a single scalar and use the s/// given above.

You can use the 'perldoc' program to access some of Perl's
standard documentation. You might want to learn about the
$/ special variable in:

   perldoc perlvar


But you don't really need to slurp the whole file, so let's do
it without that. The real problem is that by the time you know
you want to delete the newline, it has already been output from
the previous loop iteration.

Save the string from the last iteration, then print it when
you know what you want to do with the newline:


-------------------
#!/usr/bin/perl -w
use strict;

my $prev_line = '';  # remember the previous line here

while (<DATA>)  {
    if ( s/^        / / ) {  # found a continuation line
       chomp $prev_line;     # no newline for the print this time
    }
    print $prev_line;
    $prev_line = $_;         # update previous to current
}
print $prev_line;            # don't forget the last line
-------------------


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


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

Date: Thu, 28 Dec 2000 20:40:19 -0800
From: MarkyMoon <markymoon@zenbydesign.com>
Subject: Newbie with Session Key and META questions
Message-Id: <3A4C15A9.F92C6781@zenbydesign.com>

Hi, 

 I'm fairly new to PERL/CGI (about 4 months). I've been lurking here for a
month or so, so I've definately picked up on the whole Perldoc/RTFM concept (I
am and
will continue to do so!) and it is with great fear and loathing that I'm
making my first post here... having seen what can happen to you if you don't.
I have two unconnected questions. The first one may seem fairly simple but I
think the second one might be a little (O.K. a lot!) beyond my level right
now.So here goes...

1. If I'm trying to generate web pages on the fly using CGI will the resulting
pages still be indexable on search engines/bots using META info?

2. I've run across a few sites that display the number of users that are
_currently_ logged  onto a web site (i.e. # registered users/# guests). I can
understand how users could be tracked coming into a site (or maybe opens a
different page in a new window) using cookies, but how do I determine when a
user leaves the site? Could this be done using some sort of temporary
cookie/session key combo? Is it possible to create a session key that expires
after x minutes if there no new request but is refreshed if the user selects a
new page within the site's domain?

I'm really not looking for anyone to tell me HOW to do it, but I would be
really appreciative if anyone could tell me if I'm barking up the wrong tree
and need to look elsewhere. 

Thanks in advance for any hints.
Mark Smith 
-- 

That pesky MarkyMoon guy
ICQ # 26162135


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

Date: 29 Dec 2000 04:21:43 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Piping output from one script into another
Message-Id: <92h3gn$ssk$1@216.155.32.187>

In article <qsy26.30103$59.9269492@news3.rdc1.on.home.com>, Arcana 
<emerald-arcana@home.com> wrote:

 | Hi,
 | 
 | I have a Perl script that prints stuff to the screen using "print".  (It 
 | prints a variable-length record to the screen).  The script is called 
 | "psheet.pl" and it accepts 1 argument, a filename.
 | 
 | I want to be able to pipe this output into the arguments of another Perl 
 | script (so that the record from Script 1 becomes the arguments for 
 | Script 

well you could always use Storable.pm to pass the variables if all else 
fails. :/ Sorry that I don't yet know of an answer to your problem in 
the means that you wish to use.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

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


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