[9275] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2870 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 14 14:07:23 1998

Date: Sun, 14 Jun 98 11:00:43 -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           Sun, 14 Jun 1998     Volume: 8 Number: 2870

Today's topics:
    Re: [Q] Help creating a perl cgi script  -  word1.txt [ (Jonathan Stowe)
    Re: Apache and Perl (Jonathan Stowe)
    Re: Benchmark module in Perl for Win32 (Allan M. Due)
    Re: conditional curiosity... <jdf@pobox.com>
        Crash (THarris97)
        double newbie pid problem <philippos@bigfoot.com>
    Re: flock on Win32 (Thomas Berger)
    Re: Have we got a good free Perl manual? <barmar@bbnplanet.com>
    Re: Have we got a good free Perl manual? (Nathan V. Patwardhan)
        Help me Please - newbie <orbital@zetnet.co.uk>
    Re: Help me Please - newbie (Florian Kuehnert)
    Re: HELP! (Jonathan Stowe)
    Re: how to honestly make money fast... (Jonathan Stowe)
        I have looked everywhere! <chris@microdeal.co.uk>
    Re: I have looked everywhere! (Jeremy D. Zawodny)
        Premature End Of File reading a mail file <SPAM@people.demon.co.uk>
    Re: Premature End Of File reading a mail file (Jonathan Stowe)
    Re: Premature End Of File reading a mail file <SPAM@people.demon.co.uk>
    Re: Problems with <*> or <*.*> (Jonathan Stowe)
    Re: Problems with installing perl in win 95 .... <hollerud@online.no>
    Re: Problems with installing perl in win 95 .... (Jonathan Stowe)
    Re: Puzzle challenge (clarified) (Daniel Grisinger)
    Re: Puzzle challenge <philh@asptech.com>
    Re: Read the last record in a file (Bob Trieger)
    Re: Read the last record in a file (Mark-Jason Dominus)
    Re: Return values of comparison operators (Mark-Jason Dominus)
    Re: REVIEW: Perl CGI Programming - No Experience Requir (Stefaan A Eeckels)
        Using 'use' within a package? Good style? jon@amxdigital.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 14 Jun 1998 12:44:45 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: [Q] Help creating a perl cgi script  -  word1.txt [1/1]
Message-Id: <3583c0b3.5637611@news.btinternet.com>

On 13 Jun 1998 19:35:02 GMT, anonymous wrote :

>
>Thanks for your fast responds. I have not started this at all since I am
>not a expert in perl. I was wondering if someone might be able to write
>one so I can learn from that.
> 

Ho,ho.

Maybe I could throw in a crate of Moet et Chandon and a Kilo of
Columbian Marching powder too.

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



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

Date: Sun, 14 Jun 1998 11:59:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Apache and Perl
Message-Id: <3583aff2.1508844@news.btinternet.com>

On Sat, 13 Jun 1998 23:12:49 -0400, Patrick Lanphier wrote :

>What are the settings for the srm file for Apache so the when the file
>extension pl or plx is used it will automatically fire the Perl interpreter?
>Better yet has anybody compiled the modperl for NT for version 1.3b7 of
>Apache?
>

Whilst I dont want to seem unhelpful you really dont want to be asking
a question of that nature here: the same could be said to apply to
files with .py extensions being run by python or .log files being run
by LOGO.

You might however trying asking at:

comp.infosystems.www.servers.ms-windows

Or better still the FAQ for that newsgroup and the documentation for
the server.

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



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

Date: 14 Jun 1998 12:14:25 GMT
From: due@murray.fordham.edu (Allan M. Due)
Subject: Re: Benchmark module in Perl for Win32
Message-Id: <6m0er1$rtd$0@206.165.146.64>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <35830F61.CB096B@stuttgart.netsurf.de>, Jochen Froehlich 
(jf@stuttgart.netsurf.de) posted...
|Hi everyone,
|
|I tried to 'use Benchmark' with Perl for Win32 Build 316 on NT and
|got the following message:
|Benchmark: timing 100000 iterations of a, b...
|times not implemented at D:\usr\lib/Benchmark.pm line 274.
|
|Line 274 in D:\usr\lib/Benchmark.pm is:
|sub new { my(@t)=(time, times); print "new=@t\n" if $debug; bless \@t; }
|
|The question is:
|  How can 'Benchmark' be used with Perl for Win32 if 'times'
|  is not implemented there (as the error message indicates)?
|
Benchmark works fine in Gurusamy Sarathy's binary version of Perl, perhaps 
a newer version of Perl is in order?

http://www.perl.com/latest.html

AmD
-- 
Allan M. Due
Due@Murray.Fordham.edu

The beginning of wisdom is the definitions of terms.
- Socrates


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

Date: 14 Jun 1998 13:36:09 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Brent Verner" <damonbrent@earthlink.net>
Subject: Re: conditional curiosity...
Message-Id: <sol7zv8m.fsf@mailhost.panix.com>

"Brent Verner" <REPLY_TO_damonbrent@earthlink.net> writes:

> so, all is equal as far as the machine is concerned?  ...  or does the
> machine like one more than the other?

Brent - since you seem *very* interested in the performance of one
approach vs. another, this is a perfect opportunity for you to learn
how to use the Benchmark module that comes with perl.  Here's one
way.  When you've absorbed this, go ahead and

   C:\> perldoc Benchmark

   #!//c/perl/bin/perl -w
   use Benchmark;
   timethese(
	     500_000, 
	     {
	      MODIFIER => sub { my $b = 3; my $a = $b if $b },
	      IF_BLOCK => sub { my $b = 3; if ($b) { $a = $b } }
	     });
   __END__

   Benchmark: timing 500000 iterations of IF_BLOCK, MODIFIER...
     IF_BLOCK:  4 secs ( 2.62 usr  0.00 sys =  2.62 cpu)
     MODIFIER:  4 secs ( 2.80 usr  0.00 sys =  2.80 cpu)

In my mind, .18 seconds over half a million iterations is no
difference.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 14 Jun 1998 12:47:28 GMT
From: tharris97@aol.com (THarris97)
Subject: Crash
Message-Id: <1998061412472800.IAA16168@ladder03.news.aol.com>

Does any one have a script to "examin" the output of the Unix crash command?

Jeremy


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

Date: Sun, 14 Jun 1998 15:47:07 +0000
From: Philip Antoniades <philippos@bigfoot.com>
Subject: double newbie pid problem
Message-Id: <3583F07B.29F27829@bigfoot.com>

i am new to both the worlds of perl and UN*X (sp. Linux) programming,
and i am having trouble getting child process id's in a perl script.

in a nutshell, i want to invoke pppd, so some stuff, and then kill it.

but invoking with system() does not return the pid, and fork() does not
let me run a process in the new pid.  that last sentence alone should
illustrate the degree of my confusion.

is the best way to just start it, and grep through a ps call?  from the
literature i assume i am missing a fundamental concept here.

thanks,

philip



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

Date: 11 Jun 1998 19:19:37 GMT
From: ThB.com@t-online.de (Thomas Berger)
Subject: Re: flock on Win32
Message-Id: <6lpak9$gh1$1@news00.btx.dtag.de>

On Thu, 11 Jun 1998 11:44:31 -0700, Jim Bowlin <bowlin@sirius.com>
wrote:

>1) flock() is supported by the Win32 port of Perl.  It works under NT
>but not Win95.  I don't know the *why* of this.  It could be that if
>you use the NTFS instead of the FAT file system that flock() will
>work for you.

If I remember correctly the reason is that flocking is performed by
means of LockFileEx() which to my understandig is just the
asynchroneous variant of LockFile(). Unfortunately enough,
only the latter exists in Windows 95.

So I can explain the 'how' but not the 'why'...

HTH anyway Thomas
Thomas Berger


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

Date: Sun, 14 Jun 1998 17:00:59 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <flTg1.17$V%5.590065@cam-news-reader1.bbnplanet.com>

In article <m2u35ojs0z.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>,
David Kastrup  <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> wrote:
>lehman@visi.com (Todd Lehman) writes:
>> 'Pissing on' was a poor word choice.  He didn't.  What he was doing was
>> looking down on ORA and the Perl book authors as if they did something
>> wrong by not contributing the documentation freely and as if there is
>> anyone alive who has been hurt by that.
>
>Please come up with an actual quote to underline your wild
>accusations.  RMS does not talk about people doing something wrong or
>looking down or whatever else you wildly assume.  He just says that
>non-free books don't fit his demands and are inappropriate as
>documentation for free software.

Well, the words he often chooses are easily misinterpreted.  For instance,
his references to the existing Perl documentation said, "but they were no
good because they weren't free."  By "no good" he meant "not acceptable" or
"not appropriate", but it's easy to understand why people would interpret
it as "not good" == "bad".

-- 
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.


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

Date: 14 Jun 1998 17:30:45 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6m11c5$9gd@fridge.shore.net>

Barry Margolin (barmar@bbnplanet.com) wrote:

: Well, the words he often chooses are easily misinterpreted.  For instance,
: his references to the existing Perl documentation said, "but they were no
: good because they weren't free."  By "no good" he meant "not acceptable" or
: "not appropriate", but it's easy to understand why people would interpret
: it as "not good" == "bad".

I'm not sure what's worse, his intended meaning or what the words
deceive the unfamiliar reader into thinking.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: 14 Jun 1998 12:09:00 GMT
From: "James Yarwood" <orbital@zetnet.co.uk>
Subject: Help me Please - newbie
Message-Id: <01bd978c$ed29d800$0c29f7c2@abc>

Any one know where I can get a good Tutorial on using Perl for P.C.
Preferably PDF format or zip file for download!


Cheers


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

Date: 14 Jun 1998 15:36:09 GMT
From: sutok@gmx.de (Florian Kuehnert)
Subject: Re: Help me Please - newbie
Message-Id: <slrn6o7rf9.e60.sutok@babelon.in-brb.de>

James Yarwood schrieb/wrote/icrivait/ha scritto:
>Any one know where I can get a good Tutorial on using Perl for P.C.
>Preferably PDF format or zip file for download!

Good documentation is provided with perl, but there is no good tutorial
on the Internet. If you want to get a good tutorial, look for "Learning
perl" by O'Reilly.

  Florian
-- 
"Warum kostet Linux nichts?
 Warum gibt es kein einheitliches Frontend?"
        -- aus "Wie starte ich einen Endlos-Thread?", Teil 1327
           (Holger Schauer in dcolm)


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

Date: Sun, 14 Jun 1998 11:59:02 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: HELP!
Message-Id: <3583abcf.449506@news.btinternet.com>

On 14 Jun 1998 08:18:51 GMT, Craig Berry wrote :

>
>Me, I just wish we could ditch the black-hen-blood requirement.  Ever try
>getting that stuff out of a light-colored carpet?
>
It could be done but performance would suffer.  Did you amswer yes to
the "obsidian tiles" option in Configure - this does away with the
need for carpet altogether.  I do however still have a problem with
the chickens when running jobs in cron a possible work around is to
site the system in a battery hen farm and explicitly import the
chickens at compile time but of course then you begin to fowl your
namespace.

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



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

Date: Sun, 14 Jun 1998 12:44:47 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: how to honestly make money fast...
Message-Id: <3583c496.6478129@news.btinternet.com>

On 13 Jun 1998 21:52:00 GMT, Charlie Pratt wrote :

>

Ha,
A true Idler
Nice one.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 14 Jun 1998 14:29:14 -0700
From: Chris Denman <chris@microdeal.co.uk>
Subject: I have looked everywhere!
Message-Id: <358440A9.6B855D39@microdeal.co.uk>

How can I get live data from a Microsoft Access database file?

Are there any conversion files that can turn an Access file to
flatbase?  This way every 1000 accesses to my perl would
instigate this conversion utility and then read the ascii stuff.

I would we well happy if someone could help me out.

Chris D



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

Date: 14 Jun 1998 10:25:12 -0400
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: I have looked everywhere!
Message-Id: <m3hg1onjqv.fsf@peach.z.org>

Chris Denman <chris@microdeal.co.uk> writes:

> How can I get live data from a Microsoft Access database file?

Use Access, maybe?

> Are there any conversion files that can turn an Access file to
> flatbase?

You can probably export from Access to CSV.

> This way every 1000 accesses to my perl would
> instigate this conversion utility and then read the ascii stuff.

> I would we well happy if someone could help me out.

You could just use ADO via Perl for Win32. I've done that before and
it works quite well. But that's really an ADO issue, and not a Perl
issue.

Jeremy
-- 
Jeremy D. Zawodny                   Web Geek, Perl Hacker, etc.
http://www.wcnet.org/~jzawodn/      jzawodn@wcnet.org

LOAD "LINUX",8,1


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

Date: Sun, 14 Jun 1998 11:35:56 +0100
From: "Chris" <SPAM@people.demon.co.uk>
Subject: Premature End Of File reading a mail file
Message-Id: <897820570.13391.0.nnrp-08.9e98a08c@news.demon.co.uk>

I'm new to this, but checked the group for this problem.

I'm working with Perl 5 on my PC.

I am reading my Outlook Express email mbx file, but
my Perl script (whose outer-most loop is just
"WHILE (<ARGV>)") terminates a small way in to the
file, presumably because it thinks it found the end.

So two questions:

1. How does Perl define EOF ?
2. How do I redefine it ?

Thanks for any help you can offer.

Rgds, CW




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

Date: Sun, 14 Jun 1998 11:59:04 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Premature End Of File reading a mail file
Message-Id: <3583b19c.1934458@news.btinternet.com>

On Sun, 14 Jun 1998 11:35:56 +0100, Chris wrote :

>I'm new to this, but checked the group for this problem.
>
And the FAQ of course

>I'm working with Perl 5 on my PC.
>
Eh,oh

>I am reading my Outlook Express email mbx file, but

Oh my word
That will be "... that paragon of idiocy [...] the execrable Microsoft
Outlook Express 4.72.2106.4 " right ?

>my Perl script (whose outer-most loop is just
>"WHILE (<ARGV>)") terminates a small way in to the
>file, presumably because it thinks it found the end.
>
>So two questions:
>
>1. How does Perl define EOF ?

The same way your OS does

>2. How do I redefine it ?

You cant.

But you can ask Perl to treat it in a different way. Nay ignore it.
This requires the use of a Perl builtin.

You will find will find a discussion of these matters in perlfaq4 in
the section entitled:

How do I handle binary data correctly?

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



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

Date: Sun, 14 Jun 1998 15:35:42 +0100
From: "Chris" <SPAM@people.demon.co.uk>
Subject: Re: Premature End Of File reading a mail file
Message-Id: <897834951.19294.0.nnrp-08.9e98a08c@news.demon.co.uk>

Thanks Jonathon,

Binmode it in, then.

>But you can ask Perl to treat it in a different way. Nay ignore it.
>This requires the use of a Perl builtin.
>You will find will find a discussion of these matters in perlfaq4 in
>the section entitled:




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

Date: Sun, 14 Jun 1998 12:44:46 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Problems with <*> or <*.*>
Message-Id: <3583c2a6.5982321@news.btinternet.com>

On Sat, 13 Jun 1998 21:15:42 +0200, Rotondo Roberto wrote :

>Hello
>
>statement: @link_files = @files = <*>
>
>I'm running a Perl-Script with this statement under Windows 95. On this
>statement the operatingsystem create an error -> "file or directory not
>found".
>

There are a variety of reasons that globbing doesnt work properly (I
have a strange problem myself with the djgpp port producing an
infinite list).  Some versions of Perl require a dosglob.exe or
similar but I cant remember off hand if that is the case here.  

Probably your best bet would be to do something with the
opendir/readdir builtins.  

i.e

opendir(THEDIR,".") || die "Cant open directory -$!";
@files = grep !/^\.{1,2}$/, readdir(<THEDIR>);
closedir(THEDIR);

Then carry on as before.

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



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

Date: Sun, 14 Jun 1998 12:21:11 +0200
From: "Asbjxrn Hollerud" <hollerud@online.no>
Subject: Re: Problems with installing perl in win 95 ....
Message-Id: <6m0ab1$qb4$1@news1.sol.no>

Thanks for the reply Jonathan.
I still have some questions.... (Hope you don't mind :-)

You wrote that I do note need perl in order to modify the script but in
order to run it. Now I only need to run it on the server. Does this mean
that I have to install perl on the server area ? Isn't it supposed to run if
I put it in the cgi-bin area ?

hmmmm.
You are not the only one who is confused here :-)

Thanks again for your attention.

Asbjxrn Hollerud
hollerud@sn.no







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

Date: Sun, 14 Jun 1998 12:44:43 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Problems with installing perl in win 95 ....
Message-Id: <3583bb8c.4318752@news.btinternet.com>

On Sun, 14 Jun 1998 12:21:11 +0200, Asbjxrn Hollerud wrote :

>Thanks for the reply Jonathan.
>I still have some questions.... (Hope you don't mind :-)
>

We'll see about that.

>You wrote that I do note need perl in order to modify the script but in
>order to run it. Now I only need to run it on the server. Does this mean
>that I have to install perl on the server area ? Isn't it supposed to run if
>I put it in the cgi-bin area ?
>
If the server has Perl Installed and properly configured then yes your
scripts should run when placed in the appropriate place - but this is
something you should take up with the admin of you server.  

Problems associated with the configuration of servers are properly
discussed in the appropriate newsgroup for that server.

You may nonetheless want to install Perl locally in order to test and
debug your scripts.  *Especially* when you are using third party
scripts you will find that nothing works first time.

>hmmmm.
>You are not the only one who is confused here :-)
>
I would also bear in mind that this group does not (generally) provide
support for third party scripts of unknown provenance especially where
it is apparent that the poster has no or little knowledge of Perl and
has taken few steps to resolve the problem themselves.  

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



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

Date: Sun, 14 Jun 1998 10:27:19 GMT
From: dgris@perrin.dimensional.com (Daniel Grisinger)
Subject: Re: Puzzle challenge (clarified)
Message-Id: <6m084v$vc$1@perrin.dimensional.com>

In article <6lvs3u$iup@tekka.wwa.com>,
Tushar Samant  <scribble@pobox.com> wrote:
>To add the obvious -- the "correct" algorithm may be arrived at
>by running all the suggested algorithms (and a few others) in a
>tournament... 
>
Okay.  Ten messengers delivered the following ten messages.
All components of the original message were delivered at least 
once.

This differs from Tim's original challenge in the following ways-
1. No messenger delivered the original message
2. Some messengers scrambled the order of the message, others forgot
   parts of it.  None did both, all did one.

The code that generated the scrambled messages is included below. It
is based on Mark-Jason Dominus' recent permutation code posted here 
(see the code for the reference).  This list is not in the order that 
was produced by the permutator.

1
phantasmagoria milliner dehydrogenate puerperal sexagenarian 
efferent intinction bourse heath luddite  

2
phantasmagoria bourse efferent milliner heath 
intinction dehydrogenate  luddite sexagenarian puerperal 

3
phantasmagoria heath bourse luddite dehydrogenate 
efferent intinction puerperal milliner sexagenarian  

4
puerperal intinction efferent heath milliner 
sexagenarian dehydrogenate luddite  

5
phantasmagoria puerperal intinction bourse efferent 
heath milliner sexagenarian dehydrogenate  

6
phantasmagoria puerperal intinction bourse efferent 
heath sexagenarian dehydrogenate luddite  

7
phantasmagoria intinction bourse efferent heath 
milliner dehydrogenate luddite  

8
phantasmagoria puerperal intinction bourse efferent 
milliner sexagenarian dehydrogenate luddite  

9
phantasmagoria puerperal intinction efferent milliner 
sexagenarian dehydrogenate luddite  

10
phantasmagoria bourse luddite sexagenarian dehydrogenate 
milliner intinction puerperal heath efferent 

#!/home/dgris/bin/perl
#
#
#  messenger_generator
#
#   this program generates random permutations of a set of messages
#   to help test some of the proposed solutions to Tim's posted
#   problem on clpm
#
#   it uses Mark-Jason Dominus' permutation code posted to clpm
#   in message <6kspkn$809$1@monet.op.net>
# 
#   that message is available from dejanews as-
#   http://x4.dejanews.com
#   /getdoc.xp?AN=358292592&CONTEXT=897809685.1923350573&hitnum=50
#   
use strict;

sub n2pat {
  my $i = 1;
  my $N = shift;
  my $len = shift;
  my @pat;
  while ($i <= $len + 1) {   # Should really be just ``while ($N) { ...''
    push @pat, $N % $i;
    $N = int($N/$i);
    $i++;
  }
  @pat;
}

sub pat2perm {
  my @pat = @_;
  my @source = (0 .. $#pat);
  my @perm;
  push @perm, splice(@source, (pop @pat), 1) while @pat;
  @perm;
}


sub n2perm {
  pat2perm(n2pat(@_));
}

# Utility function: Factorial with memoizing
{ my @fact = (1);
  sub factorial {
    my $n = shift;
    return $fact[$n] if defined $fact[$n];
    $fact[$n] = $n * factorial($n - 1);
  }
}



# I snipped the original message that had been hardcoded
#my @message_sent = qw /snipped out the original message/;

# how this should be done
#my @message_sent = @ARGV;
 
my %messages_received;
my $n = @message_sent;

for(1..10){
    #uncomment to assure that some messages arrive safely
    #if ($_ <= 2) { 
    #   $messages_received{$_} = \@message_sent; next; 
    #}

    if ($_ <= 4) { 
        $messages_received{$_} = [ map { $message_sent[$_] }
                                  n2perm( int( rand() * factorial($n) ), $n) ];
        next;
    }
    $messages_received{$_}     = [ map { $message_sent[$_] }
                                  drop_random($n, ($_ % 2 + 1)) ];
}

for(sort keys %messages_received){
    print join " ", @{$messages_received{$_}}[0..4], "\n";
    print join " ", 
        @{$messages_received{$_}}[5 .. $#{$messages_received{$_}}], "\n";
}

sub drop_random {
    my @return = (0  .. shift);
    for(1 .. shift) {
        splice(@return, int( rand($#return)), 1);
    }
    return(@return);
}
__END__

Regards,
Daniel











-- 
Daniel Grisinger       dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
                        Dave Clark


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

Date: Sun, 14 Jun 1998 11:02:49 -0700
From: Phil Hutchinson <philh@asptech.com>
Subject: Re: Puzzle challenge
Message-Id: <35841049.1624@asptech.com>

Nathan Torkington wrote:
> 
> Tim.Bunce@ig.co.uk (Tim Bunce) (Tim Bunce) writes:
> > The problem is to find the full list of names and the original order.
> 
> You INSTALL a FULL SET OF TOOLS, like THE LORD GOD ALMIGHTY intended.
> REPENT, ye PRISONER of BILL!  The DAY of JUDGEMENT is AT PERL!  Your
> MESSENGERS are obviously just POOR substitutes for RELIABLE PIPE
> COMMUNICATION which you'd have if you had a REAL OPERATING SYSTEM
> and not a SCURRILOUS PIECE OF TOOL-CHALLENGED COPROPHILIA!
> 

I have always wondered about things like this.....could this be a
'regular expression'?

-- 
=================================================================
Phil


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

Date: Sun, 14 Jun 1998 15:10:14 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Read the last record in a file
Message-Id: <6m0p7s$43a$2@ligarius.ultra.net>

"Brent Verner" <REPLY_TO_damonbrent@earthlink.net> wrote:

-> $array_name[$#array_name];  ## yields last line of @array_name
-> 
-> $array_name[$#array_name -1];  ## yields next to last line of @array_name

This is a rather sloppy way of writing:

pop @arrayname;

perldoc -f pop

HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
    and hang up when the recording starts. "


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

Date: 14 Jun 1998 11:44:04 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Read the last record in a file
Message-Id: <6m0r44$pn7$1@monet.op.net>

In article <6lv4n2$mu3$1@nnrp1.dejanews.com>,  <info@insyte.com> wrote:
>Isn't there a simple way to "back up" one record?

Depends on your OS.  On Unix systems, the answer is `no', because Unix
files do not have `records'.  DOS-type systems the answer is similar.

Try this: 

$LINELEN = 80;  # Line length estimate---need not be exactly correct.
for (;;) {
  seek F, -$LINELEN, 2;
  read(F, $lastline, $LINELEN);
  chomp($lastline);
  last if $lastline =~ s#.*$/##o; # omit `o' if you plan to change $/
  $LINELEN *= 2;
}
# Last line of file now in $lastline


I never tested this, so watch out.


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

Date: 14 Jun 1998 11:28:53 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Return values of comparison operators
Message-Id: <6m0q7l$pkc$1@monet.op.net>
Keywords: coax Dorothy milkweed typescript


In article <Pine.SOL.3.91.980613185810.29671A-100000@abel>,
Andrew Pimlott  <pimlott@MATH.HARVARD.EDU> wrote:
>Right.  I suppose the "0 but true" trick doesn't have a place in a core 
>operator...

I think that's a happy thought, and some people like the "0 but
tttrue" trick a lot.  But unfortunately it doesn't solve the problem.
Consider:

	$x = 5;
	if (10 < $x < 20) { ... }

You wanted (10 < $x) to return 5, but 5 is true and it should return
false.  You need a backwards version of the "0 but true" trick to get
"5 but false", and there is no such trick.

Even if there were, it still wouldn't work.  Then you'd have

	10 < 5 < 20

which would evluate to 

	5 but false < 20

5 is less than 20, so the result is true, so you get

	20 true

and the final result is true, but it should have been false.  Oops.

< is an operator which returns a true or false value depending on
whether its first argument is less than its second.

It wouldn't be hard to make an operator, say %!, which just returns
its second argument.  (Some languages have this; ML for example.)

If you make < return its second argument, it isn't going to be < any
more.  It's going to be %!.

Asking for a < operator that does %! is like asking for an addition
operator that does subtraction instead of addition.  You can make one,
but then you can't use it for addition any more because it does
subtraction instead of addition.






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

Date: 14 Jun 1998 16:11:57 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6m0sod$6n1$1@justus.ecc.lu>

[courtesy cc of this posting sent to cited author via email]

In article <6luu8f$p9f$1@csnews.cs.colorado.edu>,
	Tom Christiansen <tchrist@mox.perl.com> writes:
> 
> An array has an AV associated with it.  A list is merely
> SVs sitting on a stack somewhere.  
> 
> I wish I understood why no one understands this.
This isn't something one should understand, it's something
one should _know_. IMESHO, the confusion stems from the
fact that most Perl programmers don't know enough about
interpreter/compiler construction to even moderately understand
the innards of Perl - which is as it should be.

<flame bait>
The awful^H^H^H^H^Hflexible syntax doesn't help either;
Perl can be more arcane than LISP and C++ combined ;-) 
</flame bait>

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
A consultant is a person who borrows your watch, tells you what
  time it is, pockets the watch, and sends you a bill for it.


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

Date: Sun, 14 Jun 1998 12:54:31 GMT
From: jon@amxdigital.com
Subject: Using 'use' within a package? Good style?
Message-Id: <6m0h67$p95$1@nnrp1.dejanews.com>

I'm a bit new to OOP, but I've read Tom's tutorial and a few books.

I've got a package that needs to make use of objects and functions in other
packages. (File::Find, and HTML::LinkExtor, in fact). If I do this in my .pm
file:

package foo;
use File::Find;
use HTML::LinkExtor;

Then all works as expected (i.e. as if I wasn't writing a package, but a bnch
of ordinary subroutines)

But if instead I put the use statements in my .pl file:

use File::Find;
use HTML::LinkExtor;
use foo;

Then it complains. It seems that now package foo has to use fully qualified
names, and refer to the functions in File::Find as &File::Find::find (for
example).

So which is the better way to do it? I tried reading up on inheritance (I'm
not even sure if this _is_ inheritance), and doing thing with @ISA but I got
scary messages about autoloading (which I don't understand). What should I be
doing?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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