[10047] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3639 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 4 20:06:03 1998

Date: Fri, 4 Sep 98 17:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 4 Sep 1998     Volume: 8 Number: 3639

Today's topics:
    Re: "reading line by line from a file until condition i <ericsmal@xs4all.nl>
    Re: "reading line by line from a file until condition i (Larry Rosler)
        "use" in subroutines (John Siracusa)
    Re: "use" in subroutines <rra@stanford.edu>
    Re: "use" in subroutines (Mark-Jason Dominus)
    Re: bricht Apache wegen CGI Error ab? <eashton@bbnplanet.com>
    Re: BSDI 3.0 and Compiling Perl5.004_04 <khera@kciLink.com>
    Re: COBOL and Perl <d-edwards@nospam.uchicago.edu>
        Configure Perl32 for IIS4 (Bim Paras)
    Re: Denver/Boulder Perl Mongers (David Adler)
    Re: Does open() lock the file? <khera@kciLink.com>
    Re: Execute END{} at CGI termination? <mooneer@earthlink.net>
    Re: Execute END{} at CGI termination? (Larry Rosler)
    Re: Execute END{} at CGI termination? (Charles DeRykus)
    Re: Execute END{} at CGI termination? <mooneer@earthlink.net>
    Re: grouping list of ARRAY refs with grep ? (Craig Berry)
    Re: Hats off to Tom Phoenix <dan@fearsome.net>
    Re: Hats off to Tom Phoenix (Larry Rosler)
    Re: Hats off to Tom Phoenix (Alastair)
    Re: Hats off to Tom Phoenix <rra@stanford.edu>
    Re: Hats off to Tom Phoenix (David Adler)
    Re: Hats off to Tom Phoenix (Alastair)
    Re: Help with regular expression (Jonathan Stowe)
    Re: Help-about install Perl on NT 4 (Jonathan Stowe)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 04 Sep 1998 23:50:53 +0200
From: Eric Smalley <ericsmal@xs4all.nl>
Subject: Re: "reading line by line from a file until condition is met"
Message-Id: <35F0605A.1767758E@xs4all.nl>

lsgs@my-dejanews.com wrote:
> 
> Hi,
> 
> I'm a newbie. I'm trying to read a list from a file that has
> two variables, "name" and "password" (see this portion of
> the script below). When the correct name and password are
> entered, the user has access to another area of the site. I can't
> get the while statement to work and I'm not sure what I'm
> doing wrong. Any help will be appreciated.
> 
> if ($query eq "home"){
> 
>   open (DATABASE,"new_data/list.db") || die("Cannot open
> database: $!");
> 
>    while (<DATABASE>) {
>           @record = split(/\:/, $_);
>       if ($record[0] eq $name and $record[1] eq $passwd) {


I'm pretty new at this too, but are you sure you are able to use "and"
instead of "&&"?

Good luck!
Eric


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

Date: Fri, 4 Sep 1998 15:17:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: "reading line by line from a file until condition is met"
Message-Id: <MPG.105a06ba2f04bb45989794@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35F0605A.1767758E@xs4all.nl> on Fri, 04 Sep 1998 23:50:53 
+0200, Eric Smalley <ericsmal@xs4all.nl> says...
> lsgs@my-dejanews.com wrote:
 ...
> >       if ($record[0] eq $name and $record[1] eq $passwd) {
> 
> I'm pretty new at this too, but are you sure you are able to use "and"
> instead of "&&"?

Why not?  But also, in this case, why?  We have discussed the possiblity 
of reserving the very-low-precedence 'and' and 'or' to denote control-
flow changes, rather than merely conjunction or disjunction of Booleans.

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


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

Date: 4 Sep 1998 23:06:27 GMT
From: macintsh@cs.bu.edu (John Siracusa)
Subject: "use" in subroutines
Message-Id: <6sprpj$mhi$1@news1.bu.edu>

# Main body of the script goes here...

[snip]

sub foo
{
  use MyModule;
  # Do stuff...
}

---

Will MyModule be interpreted and imported if foo() is never called in a
particular execution of the script?  Put another way, what's the best
way to keep a module from being loaded if the particular subroutine
that needs it is never executed?  Also, what is the behavior when foo()
is called multiple times?

The docs say that "use" is equivalent to "require" and "import" in a
BEGIN block, in which case it seems to me that any "use" directive in a
script will cause a module to be loaded even if the block that the "use"
statement is in is never reached.  "require" seems to be a run-time
thing in that it won't do anything unless it's in a block that's
reached during execution.  Is this a better choice, then?

sub foo
{
  require MyModule;
  import MyModule;
  # stuff...
}

I'm not just asking what will actually work, I'm asking what the
"accepeted" method for doing this is.  I see a lot of "use"ing inside
subroutines in CPAN modules, but it seems like a bad idea to me.
What's the word?

-----------------+----------------------------------------
  John Siracusa  | If you only have a hammer, you tend to
 macintsh@bu.edu | see every problem as a nail. -- Maslow


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

Date: 04 Sep 1998 16:26:51 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: "use" in subroutines
Message-Id: <m367f3o3wk.fsf@windlord.Stanford.EDU>

John Siracusa <macintsh@cs.bu.edu> writes:

> # Main body of the script goes here...
> [snip]

> sub foo
> {
>   use MyModule;
>   # Do stuff...
> }

> Will MyModule be interpreted and imported if foo() is never called in a
> particular execution of the script?

Yeah.  use doesn't work quite the way that you want for that sort of
thing; use directives are executed at compile time rather than at runtime,
so they end up happening somewhat regardless of scope (although their
effects may be scoped).

> Put another way, what's the best way to keep a module from being loaded
> if the particular subroutine that needs it is never executed?

You want to use require instead, as you mention below.

> Also, what is the behavior when foo() is called multiple times?

use (and require) maintain a hash in %INC of the modules that have already
been loaded, so the cost of executing a use or require again after it has
already been run is just a hash lookup.  Fairly minimal.  The module is
not loaded again.

> The docs say that "use" is equivalent to "require" and "import" in a
> BEGIN block, in which case it seems to me that any "use" directive in a
> script will cause a module to be loaded even if the block that the "use"
> statement is in is never reached.  "require" seems to be a run-time
> thing in that it won't do anything unless it's in a block that's reached
> during execution.  Is this a better choice, then?

Yup.

> sub foo
> {
>   require MyModule;
>   import MyModule;
>   # stuff...
> }

> I'm not just asking what will actually work, I'm asking what the
> "accepeted" method for doing this is.  I see a lot of "use"ing inside
> subroutines in CPAN modules, but it seems like a bad idea to me.  What's
> the word?

Well, it depends on what you're using.  If it's a pragma, that's quite
often a different situation entirely.  But yeah, in general I'd say that
use within a block is probably bad.

I generally use "require" and don't bother with the import, just fully
qualifying the sub names instead.  For example:

        if ($something_failed) {
            require Carp;
            Carp::croak ("failure message");
        }

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 4 Sep 1998 19:53:04 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: "use" in subroutines
Message-Id: <6spuh0$42r$1@monet.op.net>

In article <6sprpj$mhi$1@news1.bu.edu>,
John Siracusa <macintsh@cs.bu.edu> wrote:
>sub foo
>{
>  use MyModule;
>  # Do stuff...
>}
>
>---
>
>Will MyModule be interpreted and imported if foo() is never called in a
>particular execution of the script?

Yes, it will.


>sub foo
>{
>  require MyModule;
>  import MyModule;
>  # stuff...
>}

If `foo' is called multiple times, this will call `import' multiple
times too.  This is probably undesirable.  One possible solution:

>sub foo
>{
>  require MyModule;
>  import MyModule unless $imported{MyModule}++;
>  # stuff...
>}

It seems to me there's a better solution, but I can't think offhand
what it is.

>I'm not just asking what will actually work, I'm asking what the
>"accepeted" method for doing this is.  I see a lot of "use"ing inside
>subroutines in CPAN modules, but it seems like a bad idea to me.
>What's the word?

It's often a bad idea.


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

Date: Fri, 04 Sep 1998 22:33:43 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: bricht Apache wegen CGI Error ab?
Message-Id: <35F06870.52490A02@bbnplanet.com>

dieses klingt wie eine indexkonfiguration ausgabe, oder vielleicht eine
apachekonfiguration ausgabe. mvglicherweise kvnnen sie unterst|tzung an
http://www.apache.org finden. gutes gl|ck und ich hoffen da_ dieses
hilft! 

e.


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

Date: 04 Sep 1998 18:56:24 -0400
From: Vivek Khera <khera@kciLink.com>
Subject: Re: BSDI 3.0 and Compiling Perl5.004_04
Message-Id: <x77lzjh4h3.fsf@kci.kciLink.com>

>>>>> "NVP" == Nathan V Patwardhan <nvp@shore.net> writes:

NVP> : I'm trying to compile Perl5.004_04 on a BSDI 3.0x i386 system. It
NVP> : won't compile!

NVP> Definitely check the perl5-porters mailing list archives for a patch
NVP> (yes there was one posted about two months ago, I think).  All you
NVP> really need is a hints/bsdos.sh patch (which I don't have on this
NVP> filesystem at this sec -- sorry).

Perl 5.004_04 compiles perfectly fine on 3.0, but 3.1 needs the patch
to the hints file.  Said patch has been posted by me several times to
the bsdi-users mailing list, which is archived as http://www.nexial.nl/

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-301-258-8292
PGP/MIME spoken here              http://www.kciLink.com/home/khera/


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

Date: Fri, 4 Sep 1998 21:59:57 GMT
From: Darrin Edwards <d-edwards@nospam.uchicago.edu>
Subject: Re: COBOL and Perl
Message-Id: <tglnnz8roi.fsf@noise.bsd.uchicago.edu>

scm@enterprise.net (Shaun C. Murray) writes:

> 
> In article <tgu32qv43y.fsf@noise.bsd.uchicago.edu>, 
> d-edwards@nospam.uchicago.edu says...
> >
> >Obviously if one doesn't know the syntax of a language, getting
> >semantics out of a particular utterance in the language is going
> >to be tricky; that doesn't seem to me to be peculiar to perl though.
> 
> Sure but designing a language that involves cryptic symbols which have to be 
> learned rather than english words seems a bit silly to me.

Well, I think that depends on the problem domain the language is
designed to handle.  Again, I don't think this criticism is particular
to perl; similar arguments could be made about most computer languages,
mathematical notation, etc.  Usually the symbols are not intended
to deceive or be "cryptic," but to make the commonly used "idioms"
of the language... what's the word I'm looking for... succinct.

Silly e.g.: I don't think "a*b" is much more cryptic than "a times b,"
but then I wouldn't call the latter "much more verbose."  As the
problems you typically deal with get more and more complicated than
multiplication, though, the dilemma of choosing between "more cryptic"
and "more verbose" (farther from / closer to the "English description"
of the operation the notation stands for) gets harder and harder.

> COBOL isn't 
> prefectly natural but parsers weren't up to much back in the 1960's.
> 
> I'd hope that any modern language would have a better parser so you could 
> express yourself in a more naturalistic way. 

What seems like a natural expression for one kind of problem can
be very unnatural for a different problem.  Think of expressing,
say, the definite integral of a given function in a language
environment like Matlab or Mathematica... very compact; whereas
most computer languages would require (at the very least) an explicit
loop over the variable of integration.  Even in perl that might
not be "pretty" :).  But turn to a different problem space - handling
text strings, say - and suddenly Matlab is looking really klunky
(I've had to do this :( ) on tasks that become one-liners in perl.

> >(I haven't understood any of the (really _very_ few) lines of COBOL...
> 
> I find that difficult to believe. I came to COBOL straight from BASIC and it 
> didn't take me very long to undertand how to lay out a program in the
> correct sections. The actual syntax is simple. Usually you can just type
> what your thinking and compile it straight away.
> 
> eg. 
>
>    perform test-data until data-rec is true
> 
>    move 10 to percentage
> 
>    display "hello"
> 
>    open input data-file
>    read data-record
>       at end 
>         display "end of file"
>       not at end 
>         add 1 to rec-no
>    end-read
>    close data-file
>    stop run

If I say that I really don't understand whether "test-data" and
"data-rec" here are builtin operators, user-supplied functions, or
actual data chunks, I hope you won't think I'm being facetious.  I
mean yes, I have a vague idea of what's going on... the loop is
counting the records in the data-file, yes?  But if it's doing more
than that I honestly missed it.  Is data-file the actual filename, or
is it a variable for a filename supplied elsewhere?  Is this supposed to
print anything other than "hello" & "end of file"?  I was expecting it
to print out rec-no at some point, is that var. just for the program to
keep track of where it is in the file?

Obviously I could learn all of these things about COBOL, just
as you could learn enough about perl to understand the tab-splitting
example from a few posts back.

> It's verbose but then so is English. The punctuation makes sense.

perl punctuation makes sense if you know perl. :) Seriously, let's
take a simple example: line-termination chars vs. line-continuation
chars.  Since I don't see any of the former in your example, I'm gonna
guess that COBOL uses some punctuation to denote that a line is
continued on the next, i.e. that two or more lines of source code should
be treated as a "unit".  E.g. in matlab you'd end the line with
an ellipsis (...), in FORTRAN you'd start the next line with a "*".
So it'd be unfair of me to criticize COBOL just for using
punctuation for this (COBOL's not alone in this), just as I
think it's unfair to criticize perl for using a semicolon
to end a line (perl's not alone in this).

> No curley braces, semi-colons or colons in sight.

To sum up an already long post: I don't think this is a criticism
of perl per se (these features are shared by many languages).
While some problems might be readily, even preferably, tackled
using a very English-like language, for other problems this approach
can become at best tedious, at worst frustratingly complex.

> I don't want to learn shorthand as 
> only people who know shorthand can read it.
Even if you needed to take lots+lots of notes realtime?
E.g. med school, legal secretary? :) IMHO it depends on what one's doing.

Darrin


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

Date: Fri, 04 Sep 1998 22:16:07 GMT
From: bimp@bigfoot.com (Bim Paras)
Subject: Configure Perl32 for IIS4
Message-Id: <35f065ef.269493300@news.catapult.net>


Can anyone please tell me how to get Perl32 working on IIS4. I know
there's something you have to do in the registry. Do you also have to
configure something in IIS4? Please reply to bimp@bigfoot.com. Thanks

Bim Paras
bimp@bigfoot.com


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

Date: 4 Sep 1998 23:10:59 GMT
From: dha@panix.com (David Adler)
Subject: Re: Denver/Boulder Perl Mongers
Message-Id: <6sps23$et1@news1.panix.com>

>It may just be that I'm in Boulder not Denver, but it seems
>counterproductive to hold a get together at a beer-drinking place 
>when people have to *drive* home. :-(

Hmm... good thing we started Perl Mongers in New York City, where
almost *no one* drives home...  Might never have gotten off the ground
otherwise.  :_)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Hey you!  Don't watch dat!  Watch thees! This is the heavy, heavy
monster sound!" - Madness


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

Date: 04 Sep 1998 19:00:54 -0400
From: Vivek Khera <khera@kciLink.com>
Subject: Re: Does open() lock the file?
Message-Id: <x767f3h49l.fsf@kci.kciLink.com>

>>>>> "s" == smitzla  <smitzla@uswest.com> writes:

s> When I do an open() on a file for writing, is the file that is opened locked
s> in any way that would prevent other processes from writing to this file or

As others have pointed out, no this is not done for you automatically.

However, if you use the FileHandle module, and some constants from
Fcntl, and you happen to be on a *real* Unix system (aka BSD
4.4-derived ;-) you can do something like this:

  $fh = new FileHandle "file", O_WRONLY|O_EXLOCK
	or die "a miserable death";

which will open the file for writing, and get an exclusive lock at the 
same time.  Only once it has the lock will the call return.  If you
want to fail if someone else has it locked, add the O_NONBLOCK flag.



-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-301-258-8292
PGP/MIME spoken here              http://www.kciLink.com/home/khera/


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

Date: Fri, 04 Sep 1998 15:32:09 -0700
From: Mooneer Salem <mooneer@earthlink.net>
To:  Larry Rosler <lr@hpl.hp.com>
Subject: Re: Execute END{} at CGI termination?
Message-Id: <35F06A69.6EA5C387@earthlink.net>

[CC'd to sender]

Larry Rosler wrote:
> 
> Thank you, ex-Convex colleague, but that isn't it.  I just double-checked
> with 'ps -ef' on my server (which runs Netscape FastTrack, not Apache).
> The server writes to the debug file when the program starts, but the code
> in END{} to write to the same file is never executed.  And the process is
> indeed terminated.
> 
> As yet another verification, I just let the program run via the web
> server to completion (on a small data set), and the debug file was
> written by END{} correctly.
> 
> So I repeat -- is it *possible* that END{} doesn't get executed when the
> program terminates via the browser 'Stop' button?  I have evidence that I
> believe is conclusive that it doesn't.  The server is somehow terminating
> the Perl program such that it doesn't get control back to END{} properly.
> 
> My NT IIS server isn't available at the moment, but I'll see if it
> behaves the same there also.
> 

Try setting $SIG{PIPE} as well as all of the other signals, like this:

$SIG{PIPE} = $SIG{HUP} = $SIG{INT} = $SIG{KILL} = $SIG{TERM} = sub {
&END };

-- 
Mooneer Salem
WEbmaster and Administrator For HyperNetMsg
(http://hypernetmsg.hypermart.net)


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

Date: Fri, 4 Sep 1998 15:56:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Execute END{} at CGI termination?
Message-Id: <MPG.105a0ffb9a335d80989796@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35F06A69.6EA5C387@earthlink.net> on Fri, 04 Sep 1998 15:32:09 
-0700, Mooneer Salem <mooneer@earthlink.net> says...
 ...
> Try setting $SIG{PIPE} as well as all of the other signals, like this:
> 
> $SIG{PIPE} = $SIG{HUP} = $SIG{INT} = $SIG{KILL} = $SIG{TERM} = sub {
> &END };

That *did* make a difference.  Now &END gets executed, four times!!!!  (I 
know this because it appends four messages to the debug file.)  Why????

But still no output to the browser (print STDOUT) from &END.  Netscape 
Navigator appends a horizontal rule and 'Transfer interrupted!' to the 
output; MSIE just stops quietly.  Where is the bit-bucket?

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


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

Date: Fri, 4 Sep 1998 22:47:17 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Execute END{} at CGI termination?
Message-Id: <Eys7At.LJL@news.boeing.com>

In article <MPG.1059e5bc27592b6f989790@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Yes, I know this may be *only* a CGI question, in which case I'd 
>appreciate a pointer rather than simply being aimed at a newsgroup.  (I 
>spend enough time in this one already :-)
>
>I initiate a long-running program via CGI from a browser.  When I 
>terminate the program via the 'Stop' on the browser, I want to see 
>accumulated results.  I have set '$| = 1', put the proper 'print' 
>statements into END{}, and set
>
>$SIG{HUP} = $SIG{INT} = $SIG{KILL} = $SIG{TERM} = sub { &END }
>
>Yet the program just dies without executing END{} at all.  I have 
>verified by inserting statements that open and print to a mode-0666 debug 
>file that the interrupt handlers are not entered, nor is the END{} 
>subroutine itself executed.
>
>I thought that END{} was always called on any exit from a Perl program, 
>but evidently not in this case.  It *is* called when I run the program 
>from the command line, of course.

 
Don't know if this'll be of any help but I threw a $SIG{PIPE} 
into the fray: 

  $SIG{HUP}...$SIG{PIPE} = sub {system "echo $_[0] | /usr/bin/mail ced"};

then bogged down screen output with a simple loop: 
   for (0..50_000) {print 'test<br>'}. 

There were usually 3-5 messages - an intial TERM and then several 
PIPES. 

Something simpler: for (0..1_000_000) {}  didn't work - no signals 
were caught and I'm not sure why.

P.S. - on an Apache server


hth,
--
Charles DeRykus


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

Date: Fri, 04 Sep 1998 16:12:36 -0700
From: Mooneer Salem <mooneer@earthlink.net>
To:  Larry Rosler <lr@hpl.hp.com>
Subject: Re: Execute END{} at CGI termination?
Message-Id: <35F073E4.4B8BC787@earthlink.net>

[Posted to comp.lang.perl.misc and a copy mailed.]

Larry Rosler wrote:
> 
> That *did* make a difference.  Now &END gets executed, four times!!!!  (I
> know this because it appends four messages to the debug file.)  Why????
> 
> But still no output to the browser (print STDOUT) from &END.  Netscape
> Navigator appends a horizontal rule and 'Transfer interrupted!' to the
> output; MSIE just stops quietly.  Where is the bit-bucket?
> 

Do these two things:

1. Put exit(0); at the end of &END
2. Change it into a NPH script, meaning adding "nph-" to the filename
and adding the following line before the line that prints out the
"Content-type:" header:

print "HTTP/1.0 200 OK\n";

-- 
Mooneer Salem
Webmaster and Administrator for HyperNetMsg
(http://hypernetmsg.hypermart.net)


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

Date: 4 Sep 1998 22:30:00 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: grouping list of ARRAY refs with grep ?
Message-Id: <6sppl8$d4v$1@marina.cinenet.net>

Phil R Lawrence (prl2@lehigh.edu) wrote:
: Hello, witness the following array:
: 
: my @beginning_list= (['abc','def','abc'],
:                     ['def','abc'],
:                     ['ghi','jkl','jkl'],
:                     ['jkl','ghi','jkl'],
:                     ['mno','pqr']
: );
: 
: I want to group together those references that share the same 1st
: two elements (regardless of order) in a new array.  So, output
: should be:
: (
:     [
:         ['abc','def','abc'],
:         ['def','abc']
:     ],
:     [
:         ['ghi','jkl','jkl'],
:         ['jkl','ghi','jkl']
:     ],
:         ['mno','pqr']
:     ]
: )

My version (note that about half of it is test harness):


#!/usr/bin/perl -w
# grouper - group arrays sharing first two elements.
# Craig Berry (19980904)
# Assumes array contents are strings for comparison purposes.

use strict;

my @beginning_list = (
     ['abc','def','abc'],
     ['def','abc'],       
     ['ghi','jkl','jkl'], 
     ['jkl','ghi','jkl'], 
     ['mno','pqr']
   );

my @groups;

OVER_INPUT:
foreach my $ar (@beginning_list) {
  my @signature = sort @$ar[0, 1];

  foreach my $hr (@groups) {
    if ($signature[0] eq ${$hr->{signature}}[0] &&
        $signature[1] eq ${$hr->{signature}}[1]) {
      push @{$hr->{members}}, $ar;
      next OVER_INPUT;
    }
  }

  push @groups, { signature => [ @signature ],
                  members   => [ $ar ] };
}

my @results = map { $_->{members} } @groups;

print "Results:\n";

foreach my $ar (@results) {
  print "Group:\n";

  foreach my $subr (@$ar) {
    print "  ( ",
          join(', ', @$subr),
          " )\n";
  }
}


---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Fri, 4 Sep 1998 22:55:21 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: Hats off to Tom Phoenix
Message-Id: <904946087.15153.0.nnrp-07.c2deb1c5@news.demon.co.uk>


Chip Salzenberg wrote in message <6spgbt$ghg$1@cyprus.atlantic.net>...

>"Hence when you go making gifts of mercy, do not blow a trumpet ahead
>of you, just as the hypocrites do in the synagogues and in the
>streets, that they may be glorified by men. Truly I say to you, They
>are having their reward in full." -- Matt. 6:2

Just for balance:

"Know ye that the friendship of the world is emnity with God? whosoever
therefore will be a friend of the world is the enemy of God" - James 4:4
(Its there, check it for yourself)

I'd hate to think anyone was using our ng for proselytzation, now, but if
you must have ya bible, then ya must have *all* ya bible, not just the nice
bits. Try reading all the bits of the bible *in between* those your preacher
tells you to. Big Guy ain't all that pleasant once you get to know him.
Quite frankly, Christianity sucks.

For the record, if people want to be a Jehovah's Witness, they have the
option of exploring that avenue themselves, they don't need someone selling
it to them. Ditto all religions. If you had atheists, Muslims, and Hindus
all turning up on your doorstep passionately explaining they were only
trying to "save you", you'd start to get pretty pissed too. Sure, from your
point of you, you're just trying to do the Right Thing (TM). From their
point of view, however, you're just a hige pain in the ass whose keeping
them from the Sunday game on the TV.

I'm an atheist, in case you still care. And I don't feel in dire need of
salvation, thank you.

--

Dan Adams
dan@fearsome.net








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

Date: Fri, 4 Sep 1998 15:13:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Hats off to Tom Phoenix
Message-Id: <MPG.105a05fee0cffe1e989793@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <904946087.15153.0.nnrp-07.c2deb1c5@news.demon.co.uk> on Fri, 
4 Sep 1998 22:55:21 +0100, Daniel Adams <dan@fearsome.net> says...
> 
> Chip Salzenberg wrote in message <6spgbt$ghg$1@cyprus.atlantic.net>...
> 
> >"Hence when you go making gifts of mercy, do not blow a trumpet ahead
> >of you, just as the hypocrites do in the synagogues and in the
> >streets, that they may be glorified by men. Truly I say to you, They
> >are having their reward in full." -- Matt. 6:2

<SNIPPED> an outrageous, disgusting, off-topic response to someone who is 
just trying to spread good feelings about Tom P, onw of the most 
important contributors here.

Please can your bigotry, or peddle it elsewhere.

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


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

Date: Fri, 04 Sep 1998 22:42:28 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Hats off to Tom Phoenix
Message-Id: <slrn6v0ut4.56.alastair@calliope.demon.co.uk>

Larry Rosler <lr@hpl.hp.com> wrote:
>
><SNIPPED> an outrageous, disgusting, off-topic response to someone who is 

Please. That was neither 'outrageous' or 'disgusting'. 'Offtopic' yes.
Chip mentioned his religious preference first. 

>Please can your bigotry, or peddle it elsewhere.

No bigotry either. Atheism appears to upset you.


-- 

Alastair
alastair@calliope.demon.co.uk
Time to put away childish things


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

Date: 04 Sep 1998 15:59:04 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Hats off to Tom Phoenix
Message-Id: <m3d89bo56v.fsf@windlord.Stanford.EDU>

Alastair <alastair@calliope.demon.co.uk> writes:

> Please. That was neither 'outrageous' or 'disgusting'. 'Offtopic' yes.
> Chip mentioned his religious preference first.

Are you in the habit of launching long diatribes against religion whenever
anyone mentions a religious preference?  Chip did so in order to make a
point about philanthropy and one's expectations of reward based on
personal experiences that weren't religious, not to discuss religion.

> No bigotry either. Atheism appears to upset you.

Evangelism offends me.  Please be so kind as to preach your religion or
lack thereof somewhere other than in a technical newsgroup.  I have no
wish to listen to you try to convert me any more than I want to listen to
Chip try to convert me.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 4 Sep 1998 23:28:24 GMT
From: dha@panix.com (David Adler)
Subject: Re: Hats off to Tom Phoenix
Message-Id: <6spt2o$et1@news1.panix.com>

On 4 Sep 1998 15:51:25 -0400, Chip Salzenberg <chip@pobox.com> wrote:
>"Hence when you go making gifts of mercy, do not blow a trumpet ahead
>of you, just as the hypocrites do in the synagogues and in the

Ah, you're just jealous 'cause you don't know how to play a ram's
horn...  

Hypocrites in Synagogues, indeed... :-)

dave, pointing out the smiley, since people seem to often miss them
during discussions of subjects such as religion

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"We Americans stand on the shoulders of freaks." - Doctor Demento


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

Date: Fri, 04 Sep 1998 23:52:35 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Hats off to Tom Phoenix
Message-Id: <slrn6v130i.56.alastair@calliope.demon.co.uk>

Russ Allbery <rra@stanford.edu> wrote:
>Alastair <alastair@calliope.demon.co.uk> writes:
>
>> Please. That was neither 'outrageous' or 'disgusting'. 'Offtopic' yes.
>> Chip mentioned his religious preference first.
>
>Are you in the habit of launching long diatribes against religion whenever
                                   ^^^^
I wouldn't call that 'long' and I'm certainly not about to _start_ discussing
religion here.

>
>Evangelism offends me.  Please be so kind as to preach your religion or
>lack thereof somewhere other than in a technical newsgroup.

Sorry sir. I wasn't preaching. I might have missed an emoticon off my first post
though :/

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Fri, 04 Sep 1998 23:05:46 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Help with regular expression
Message-Id: <35f06e95.5274777@news.btinternet.com>

On Fri, 04 Sep 1998 17:01:09 GMT, nguyen.van@imvi.bls.com wrote :

>Hi Perl Gurus,
>
>I have a list of access files which I pulled out from other place to the
>place where my perl script runs. I successfully pull out these access files
>to place and put this list of files in an array. I want to process these
>files and redirect the output to one file (i.e this file containing all
>patterns which I want to pull out from the array). The following is a example
>of my access files. 

An HTTP Proxy log eh ?

The following will pull apart your logfile into its constituent parts
- I think this is probably more instructive than splitting it up into
arbitary bits. And of course some time real soon now some pointy
haired individual is going to ask to analyse the data some other way
and you wouldnt want to have to ask again now would you ? 

This is probably not the most elegant regular expression in the world
but it appears to work at least for the data you gave (after i had
fixed up some arbitary white space.)

#!perl

while(<DATA>)
{
   if(m/(\d+\.\d+\.\d+\.\d+)\s # IP Number of client
        (\S*)\s(\S*)\s         # User ?
        \[(.*)\]\s             # Time
        "([^"]*)"\s            # Request
        (\d{3})\s              # Status
        (\d*)\s                # Size of data xfered
        "([^"\s]*)"\s          # Host
        "([^"]*)"$             # User Agent
       /x
      )
     {
  
       print "Address = ",$1,"\n";
       print "Time    = ",$4,"\n";
       print "Request = ",$5,"\n";
       print "Status  = ",$6,"\n";
       print "Amount  = ",$7,"\n";
       print "Host    = ",$8,"\n";
       print "Agent   = ",$9,"\n";
     }
}
__END__
152.163.195.181 - - [30/Jul/1998:00:01:07 -0400] "GET
X?crno=7034572&mkt=**** HTTP/1.0" 200 14122
"http://bellsouth.bigfoot.com/SEARCH" "Mozilla/2.0 (compatible ; MSIE
3.02; Update a; AK; AOL 3.0; Windows 95)"
152.163.204.136 - - [30/Jul/1998:00:01:37 -0400] "GET / HTTP/1.0" 200
23641 "http://www.florida.com/realestate/cities.html" "Mozilla/2.0
(compatible; MSIE 3.02;  Update a; AOL 3.0; Windows 95)"
209.214.81.7 - - [30/Jul/1998:00:01:37 -0400] "POST / HTTP/1.0" 200
5587 "http:/ /yp.bellsouth.com/" "Mozilla/4.04 [en] (WinNT; I)"


I would suggest reading the perlre manpage if you have any difficulty
understanding what is going on here.

/J\
-- 
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Fri, 04 Sep 1998 23:05:44 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Help-about install Perl on NT 4
Message-Id: <35f06376.4377797@news.btinternet.com>

On Fri, 04 Sep 1998 14:16:45 -0400, tao Mengtao wrote :

> After I install the perl 5 forwin32, Whenever I want to run
>the CGI file, it always jump out a frame: Username and passward requird.
>
This is almost certainly a server configuration issue and not to do
with Perl.  The behaviour suggests to me that there are restrive
permissions on your web servers directories.

>I mean I am the adm of that server, no username and passwd can be used.

Well if you dont know the answer then I suggest that you check this
out with some Newsgroup concerned with your server software.
comp.infosystems.www.servers.ms-windows springs to mind.

/J\
-- 
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3639
**************************************

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