[8462] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2079 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 11 23:07:41 1998

Date: Wed, 11 Mar 98 20:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 11 Mar 1998     Volume: 8 Number: 2079

Today's topics:
        Accessing Client Data using Perl/ODBC <chai@itrade.net>
    Re: Attaching File to perl / sendmail script <snowe@rain.org>
        building perl on NCR svr4(at&t) <justin@nectar.com.cu>
    Re: c.l.p.mod and TPI <dformosa@st.nepean.uws.edu.au>
        EEEEEK, trying to work with perl and Microsoft!! (Jason Hazzard)
    Re: Formatting telephone numbers - How to? (Peter G. Martin)
        Is perl looking in the wrong place for something?? (Michael Shavel)
    Re: Medium regex question (Abigail)
    Re: Medium regex question <uri@sysarch.com>
    Re: perl binary for SGI (Steve Morris)
    Re: Problem with "goto" in Perl (Mike Stok)
    Re: Problem with "goto" in Perl <uri@sysarch.com>
    Re: Problem with "goto" in Perl <zenin@best.com>
    Re: Q about FAQ answer - Random line from file <jdf@pobox.com>
    Re: QUIZ: answer and hash slice tutorial <lr@hpl.hp.com>
    Re: Speed of sort routine vs. one-by-one compare   (123 <snowe@rain.org>
    Re: splice -- useful uses? <tchrist@mox.perl.com>
    Re: splice -- useful uses? <uri@sysarch.com>
    Re: splitting by one or more spaces <dagon@halcyon.com>
        Test (ignore this message) <al346873@academ01.mty.itesm.mx>
        Testing a perl "CGI" script (Sporty)
    Re: Testing a perl "CGI" script <justin@nectar.com.cu>
    Re: The -w switch (was Re: better way to do this?) <joseph@5sigma.com>
    Re: Using regex to initial cap a name (Paul Neubauer)
    Re: What is PERL? Learn JAVA instead? <tchrist@mox.perl.com>
    Re: Win32::AdminMisc::GetDriveSpace and Active Server P <rothd@xrxoxtxhx.xnxextX>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Mar 1998 17:52:03 +0000
From: Chai Khoo <chai@itrade.net>
Subject: Accessing Client Data using Perl/ODBC
Message-Id: <3506CF42.2F1B6F94@itrade.net>

Hi,

  Can anyone tell me what is the best approach to read data from the
client database?  I was hoping Perl/ODBC will solve the problem for me,
but I could not find a way to talk to my client database using
Perl/ODBC.  Please let me know if there is a way to read client
database.


-chai@hotmail.com



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

Date: Wed, 11 Mar 1998 17:42:19 -0800
From: Nick Halloway <snowe@rain.org>
Subject: Re: Attaching File to perl / sendmail script
Message-Id: <Pine.SUN.3.96.980311174031.10375A-100000@coyote.rain.org>



On Wed, 11 Mar 1998, Nick Nottleman wrote:

> Is there a way to attach a file to an e-mail with perl?

Do you mean, to open a sendmail process with a filehandle as input?  
Then you write to the filehandle, when you close the filehandle the
mail is sent?

Majordomo 1.94.4 does this, you can download it from www.greatcircle.com.



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

Date: Thu, 12 Mar 1998 12:33:20 +1100
From: Justin Wills <justin@nectar.com.cu>
Subject: building perl on NCR svr4(at&t)
Message-Id: <35073B60.BC8E636B@nectar.com.cu>

has anybody done it ???

I can't get 5.003,5.004_1 or 5.004_4 to build using either the system
compiler or gcc.

anybody know where I can get a precompiled binary



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

Date: 12 Mar 1998 00:59:28 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: c.l.p.mod and TPI
Message-Id: <889664368.373957@cabal>

In <pudge-1103981102480001@ppp-49.ts-1.kin.idt.net> pudge@pobox.com (Chris Nandor) writes:

>In article <889584849.326190@cabal>, ? the platypus {aka David Formosa}
><dformosa@st.nepean.uws.edu.au> wrote:

[...]

># I was told on this thread that ads would be sent to TPI, thay would look
># at them and decide wether or not thay where apporprate to the newsgroup
># and then post them. In other words thay are acting just as a moderator
># would.

>No, they are not.  Don't spread lies.

I was acting in good fath based on what had been printed on this
newsgroup.  This is I suppose irrelvent now as the charter has been
changed to fix the problem I felt was present.

>  Even were this to be the case, this
>is only one function of being a moderator.  That's like saying that the
>Oval Office janitor is the President just because he flushes the toilet
>for Bill.

I better anogy would be this.  The Govener Genral dose all the duites that
a head of state would noramly do, however legally he is not the head of
state HRH the Queen is.  However most peaple acnolge that he is the
defacto head of state.


--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. 
Support NoCeM http://www.cm.org/                   
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Thu, 12 Mar 1998 03:34:38 GMT
From: hazzard@usa.net (Jason Hazzard)
Subject: EEEEEK, trying to work with perl and Microsoft!!
Message-Id: <MPG.f70c6db26cf6cca989696@news.direct.ca>

Hello perl geniuses, and non geniuses (like myself)

A quick question on an area I can't seem to understand....

I have written some scripts in PERL, they are actually CGI scripts which 
use DBM to create and read database files.  I have used them sucessfully 
on various systems with NDBM GDBM etc....  But all these systems were 
UNIX servers.

My question is, can these scripts run on a Microsoft IIS server?  Are DBM 
routines installed with perl, or are they native to UNIX only?  They 
didnt seem to want to work for me!  And how do I find out what packages I 
can use... GDBM seems to be the most highly recommended.


Any help you can give would be greatly appreciated, as working will this 
Bill Gates server stuff is a step in a new (terrible?) direction!

Thanks, Jay


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

Date: 12 Mar 1998 01:23:46 GMT
From: peterm@zeta.org.au (Peter G. Martin)
Subject: Re: Formatting telephone numbers - How to?
Message-Id: <6e7df2$h4q$1@phaedrus.kralizec.net.au>

In article <3505B7AD.7F0@see_signature.com>,
	NerveGas <NerveGas@see_signature.com> writes:
>> > dashes) on an html page with dashes inserted.  The database contains both
>> > US and international phone numbers.  I want to put in dashes as in the
>> > following:
>> > 999-999-9999 in all cases.
>> 
>> Just curious, but why would you want to force NANPA "looks"
>> to numbers which AREN'T part of NANPA? That doesn't seem to
>> make much sense. I mean, I'm a `Merkin and all, but isn't it
>> awful ethnocentric to say "this is the only way to write a
>> phone number"?
> 
>   Only as ethnocentric as only posting in English.  : )
 
Well,   some of speak English quite well, but have phone number
formats that don't match the 3-3-4 digit pattern.

And some of us speak English and use decimal systems, and
A4 paper.

Maybe not so much ethnocentric as isolationist ?  

-- 
Peter G. Martin, Tech.Writer & Perl User
      The Scribe & Chutney Trust
peterm@zeta.org.au,  http://www.zeta.org.au/~peterm
ROZELLE, Australia       +61 2 9818 5094




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

Date: Wed, 11 Mar 1998 22:32:22 -0500
From: mshavel@erols.com (Michael Shavel)
Subject: Is perl looking in the wrong place for something??
Message-Id: <mshavel-1103982232220001@130.9.16.207>

Hi


I have been running perl 5.00401 now for a while and all has been well
until I tried to implement Tk. 
I know this is not the correct newsgroup for Tk questions but I think this
is a perl install question.  I have noticed that when I try and do certain
things with Tk they work out fine... example -- using $main->Button() to
make a button. 
However when I try to use  $main->Entry or $main->Text I am getting the
following message:

ld.so.1: /usr/bin/perl: fatal: relocation error: symbol not found: safemalloc: r
eferenced in /usr/local/lib/perl5/site_perl/sun4-solaris/auto/Tk/Tk.so
Killed


(I see the file above has an ".so" extension. It is a binary file. Anyone
know what an ".so" file is for?)


Now, I have been poking around a bit on the system (that is running
Solaris 2.5) and find that there are some files relating to "Entry" in the
following path:

      /usr/local/lib/perl5/site_perl/auto/Tk

as opposed to the path referenced above. 

So my question is, does  perl need to be told where to look for these
files relating to "Entry" and "Text" to make then work correctly?  (and if
so how do I do that) .


thanks very much to all. 


Sincerely 

Mike Shavel
mshavel@erols.com


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

Date: 12 Mar 1998 01:13:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Medium regex question
Message-Id: <6e7csd$oae$1@client3.news.psi.net>

Chris (chris@surewould.com) wrote on 1654 September 1993 in
<URL: news:35073026.2D3EAA7B@surewould.com>:
++ I'm having a problem finding how to match a semi-complicated bunch of
++ strings. I want to match strings like these (yep, it's html):
++ 
++ <pre>    (this isn't part of the string - it's just to foil HTML-enabled
++ newsreaders, I think.)
++ 
++ <td></td>
++ <td><font size=2>+</font></td>
++ <td><font size=1>-</font></td>
++ 
++ </pre>

The above isn't valid HTML.

++ Any ideas?

You could use HTML::Parser, but since you aren't using valid HTML,
it's unclear what exactly it is that you want.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 11 Mar 1998 22:49:25 -0500
From: Uri Guttman <uri@sysarch.com>
To: chris@surewould.com
Subject: Re: Medium regex question
Message-Id: <x7yaygy3ei.fsf@sysarch.com>

Chris <chris@surewould.com> writes:

> <td></td>
> <td><font size=2>+</font></td>
> <td><font size=1>-</font></td>
> 
> In other words, I want an empty <td></td> element, or a <td></td>
> element that has either a + or - in it, which is modified by a font tag.
> Also, I'd like to be able to catch the + or - in a back reference.
> 
> My best stab is
> 
>   <td>(<font.*>([+|-])</font>)?</td>
> 
> However, if I try to match
> 
>   <td><font size=2>-</font></td>
> 
> with it, it matches, but $1 is equal to "<font size=2>-</font>", not
> just "-" as desired. I've tried a bunch of combos of parens and ? but
> nothing else even matches.

you are close but you don't win the cigar!

first you don't need the | in the [] char class. the [+-] will find
either one. | is for alternating between regexes, not chars in a class.

second, use .+, since you know there are chars after the font tag. it is
faster than .*

third, make sure you use some other regex delimiter than / since you
have / in your regex. common ones are !, # (i like | when i don't use it
in the regex).

fourth, your regex DID match the +-. you were just looking at the wrong
submatch. $1 gets the submatch for the first ( in the regex. $2 gets the
second which is [+-]. so print use $2.

m|<td>(<font.*>([+-])</font>)?</td>|


as an alternative mark the first ( with ?: so it doesn't grab the
submatch. then $1 will be the +-

m|<td>(?:<font.*>([+-])</font>)?</td>|

hope this hospital,

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 12 Mar 1998 03:46:25 GMT
From: morris@rahul.net (Steve Morris)
To: kamari@fhw.gr
Subject: Re: perl binary for SGI
Message-Id: <6e7lqh$glm$1@samba.rahul.net>

[Posted and mailed]

In article <35068BDC.554C@fhw.gr>,
	George Kamarinos <kamari@fhw.gr> writes:
> I am looking for a perl binary for an SGI Irix 6.2
> I checked CPAN but could not find it. Any pointers would be greatly
> appreciated.
> 
> Thank you
> 
> 
> 


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

Date: 12 Mar 1998 02:19:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Problem with "goto" in Perl
Message-Id: <6e7gna$fim@news-central.tiac.net>

In article <889660225.816059@thrush.omix.com>, Zenin  <zenin@best.com> wrote:
>Uri Guttman <uri@sysarch.com> wrote:
>: because goto was invented by uncle bill, lord of the evil empire :-)
>	>snip<
>
>	Goto is pretty much an ASM JMP (in use, not implementation).  Bill
>	didn't invent it.  Intel "invented" it, if anyone did.	Bill has
>	never invented anything that I can remember, DOS included (it was
>	bought from another company).

goto is very old - in modern computing terms - Dijkstra's famous paper in
the Communications of the ACM was published in early 1968.

Intel was founded in 1968 and Microsoft in 1975 (I think) so it's inlikely
that the notorious goto was invented by either of them, some form of
absolute jump is a fairly common low level instruction in real
processors...

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 11 Mar 1998 22:20:12 -0500
From: Uri Guttman <uri@sysarch.com>
To: Zenin <zenin@best.com>
Subject: Re: Problem with "goto" in Perl
Message-Id: <x767lkzjbn.fsf@sysarch.com>

Zenin <zenin@best.com> writes:

> Uri Guttman <uri@sysarch.com> wrote:
> : because goto was invented by uncle bill, lord of the evil empire :-)
> 	>snip<
> 
> 	Goto is pretty much an ASM JMP (in use, not implementation).  Bill
> 	didn't invent it.  Intel "invented" it, if anyone did.	Bill has

there were goto's in the 1950's, slightly before intel, uncle bill or
anyone of their cabal were doing any evil on the planet.  see fortran,
cobol, and other dinosaurs at your local computer museum or mainframe
shop.

> 	never invented anything that I can remember, DOS included (it was
> 	bought from another company).
> 
> 	Bill is a business man, not an inventer.

<SARCASM>
i am sorry you don't think uncle bill is a true genius and inventor of
the goto statement.
</SARCASM>

my reply was humorous as the original poster refered to the "evil"
goto. so i thought that all evil must have originated with uncle bill.

uri


-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 12 Mar 1998 03:38:11 GMT
From: Zenin <zenin@best.com>
Subject: Re: Problem with "goto" in Perl
Message-Id: <889674269.188743@thrush.omix.com>

Uri Guttman <uri@sysarch.com> wrote:
	>snip<
: my reply was humorous as the original poster refered to the "evil"
: goto. so i thought that all evil must have originated with uncle bill.

	Uncle Bill has never created anything evil.  Bill is simply vary
	good at identifying evil in any form, and buying it up before anyone
	has a chance of getting a share of the Evil Empire. :-)

	Bill didn't invent goto, but I'll bet he made money off it. :-)

-- 
-Zenin
 zenin@best.com


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

Date: 11 Mar 1998 20:02:35 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Q about FAQ answer - Random line from file
Message-Id: <pvjsvhzo.fsf@news.concentric.net>

dkw0@cdc.gov (David Wall) writes:

Do you have the blue Camel, or the pink?  You need the blue.

> rand($.) < 1 && ($line = $_) while <FILE>;

There are several rather Perlish constructs going on simultaneously,
which is itself a rather Perlish thing.

First: statement modifiers.

   foo while bar;

is shorthand for

   while (bar) { foo }

Furthermore, per perlop, 

   while (<FOO>) {}

is shorthand for

   while (defined ($_=<FOO>)) {}

which causes $_ to be assigned successive lines of the file referenced
by filehandle FOO until there are no more.

Next: the short-circuit boolean &&.  If and only if its left operand
evaluates to true then it evaluates its right operand.  So

   foo && bar

is shorthand for

   if (foo) { bar }

So, to rewrite the thing somewhat less pithily, hoping this helps,

   while (defined ($_=<FOO>)) {
      if (rand($.) < 1) {
         $line = $_;
      }
   }

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 11 Mar 1998 17:56:01 -0800
From: Larry Rosler <lr@hpl.hp.com>
To: Uri Guttman <uri@sysarch.com>
Subject: Re: QUIZ: answer and hash slice tutorial
Message-Id: <350740B1.B3127446@hpl.hp.com>

I was impressed by the submission made by Uri Guttman on March 3 about
hash slices.  In particular, I was pleased by the notational
convenience, and thought that there might also be a performance benefit
if the hash requires complex addressing.

To my surprise, I found a consistent small performance degradation,
which
I am having trouble understanding.  My very simple test program and
benchmark
results are given below.  This is perl, version 5.004_01 on HP-UX 10.20.

******************************************************************

#!/usr/local/bin/perl -w
use strict;
use diagnostics;
use Benchmark;

open OUT, '>/dev/null' or die $!;

timethese (1 << 14, {
    HashList => q{
	my %hash = ( A => 1, B => 2, C => 3, D => 4, E => 5 );
	print OUT join("\t" =>
	    $hash{A}, $hash{B}, $hash{C}, $hash{D}, $hash{E}), "\n";
    },
    HashSlice => q{
	my %hash = ( A => 1, B => 2, C => 3, D => 4, E => 5 );
	print OUT join("\t" => @hash{qw(A B C D E)}), "\n";
    },
    RefList => q{
	my $ref = { A => 1, B => 2, C => 3, D => 4, E => 5 };
	print OUT join("\t" =>
	    $ref->{A}, $ref->{B}, $ref->{C}, $ref->{D}, $ref->{E}), "\n";
    },
    RefSlice => q{
	my $ref = { A => 1, B => 2, C => 3, D => 4, E => 5 };
	print OUT join("\t" => @{$ref}{qw(A B C D E)}), "\n";
    },
} );
__END__
Benchmark: timing 16384 iterations of HashList, HashSlice, RefList,
RefSlice...
  HashList:  2 secs ( 1.80 usr  0.01 sys =  1.81 cpu)
 HashSlice:  2 secs ( 2.00 usr  0.01 sys =  2.01 cpu)
   RefList:  2 secs ( 1.91 usr  0.00 sys =  1.91 cpu)
  RefSlice:  3 secs ( 2.10 usr  0.01 sys =  2.11 cpu)

******************************************************************

Why does code that intuitively should run faster behave this way?  In
his submission, Uri stated that a script could "use hash slices to
improve its efficiency, clarity and elegance."  I agree about clarity
and elegance, but am troubled about efficiency.

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 11 Mar 1998 17:55:50 -0800
From: Nick Halloway <snowe@rain.org>
Subject: Re: Speed of sort routine vs. one-by-one compare   (123)
Message-Id: <Pine.SUN.3.96.980311174435.10375C-100000@coyote.rain.org>



On 11 Mar 1998, Abigail wrote:

> ++ What I need to do is to update a file that might have say 50,000 records,
> ++ with new records occasionally.  So it would be on disk, then either
> ++ read in record-by-record, or all of it would be read into memory.
> ++ 
> ++ By binary insertion, 
> ++ I mean a program that does something like this:  Reads the file
> ++ into memory, looks for the middle of the file, figures out whether the
> ++ new record belongs above or below the middle of the file, looks for the
> ++ middle of that half of the file, figures out where the record belongs
> ++ relative to that middle, etc.  If anyone has such a program, I'd
> ++ appreciate hearing about it.
> ++ 
> ++ For 50,000 records, is it worth doing this, or should the program just
> ++ read in the file record by record, compare each record to the new record,
> ++ then write it all out?  If it would be likely to take much more than a 
> ++ second to insert the new record with the easy method then programming the
> ++ binary method would probably be better.
> 
> 
> First of all, is the state of the file between inserts relevant?
> Do you get a record, then have to insert it, do something with
> the file, then get the next record, 

Yes, the database gets used between updates and needs to be kept 
sorted.  It's updated one record at a time.

> Furthermore, it will make a hell of a lot of difference if you have
> 50,000 records of 10 bytes each, or 50,000 records of 5000 bytes each.
> In the former case, you use half a meg of RAM by reading in the entire
> file, in the latter case, you use 250 Mb of RAM. If you have 32 Mb on
> your machine, you'll notice. And it certainly influences the "is it
> worth doing this" question.

The records are about 25 bytes long.  
The file would be sorted by length of the first record, i.e. how many
characters before the first space.

I'm running this on an ISP, and the resources are limited, so I don't
want to write something that's so sloppy about resource use it gets
noticed :)  I don't know whether doing it the easy way, reading in one
record at a time and comparing, writing out one record at a time, 
would use significant resources.

On 11 Mar 1998, Ken Fox wrote:

> I must have missed the original posting.  If the records have to be
> processed (and written back to disk) immediately, then the original
> poster is screwed.  I hope he doesn't have to insert very many
> records... ;)

One record at a time has to be inserted, but I'm keeping the program
that uses the database waiting until the database is updated, with 
lockfiles.  




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

Date: 12 Mar 1998 02:12:40 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: splice -- useful uses?
Message-Id: <6e7gao$que$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, michael@flash.net (Michael W Peterson) writes:
:On 12 Mar 1998 00:07:03 GMT, <abigail@fnx.com> wrote:
:>I hate to see a quadratic algorithm being used a an example
:>for what people use splice for if there's a linear algorithm
:>doing the same.
:>
:>Knuth's algorithm:
:>for ($i = @arr; $i; $r = rand $i --, @arr [$r, $i] = @arr [$i, $r]) {}
:
:Interestingly, the quadratic algorithm is faster (at least on my box):
:Benchmark: timing 100000 iterations of c, perl...
:         c: 50 secs (50.74 usr  0.01 sys = 50.75 cpu)
:      perl: 37 secs (36.13 usr  1.88 sys = 38.01 cpu)

Hold on there.  She's going to chew on your noggin for inappropriate
benchmarks.

You are comparing a trivial little 10 element array.
Overhead will eat you up.  Try it more like this:

    for ($N = 1; $N < 300; $N <<= 1) { 
	@a = (0 .. 9) x $N;
	** run the timing on @a here **
    }

And you'll see that Abigail's clearly wins in the long run.  You can
certainly have a situation where a quadratic algorithm (with low overhead)
can beat a linear one (with high overhead).  That's what's going on
here -- in the tiny cases, the more native way wins.  But keep doubling
your data size and you'll see what I mean.  Hers eventually pulls ahead,
as it inevitably must.  

Using just 10,000 iterations so things can get done in my lifetime,
at $N == 32, here's what happened:

    Benchmark: timing 10000 iterations of c, perl...
	     c: 55 secs (54.59 usr  0.00 sys = 54.59 cpu)
	  perl: 70 secs (41.60 usr  2.67 sys = 44.27 cpu)

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

	    Stranger does not rhyme with anger,
	    Neither does devour with clangour.


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

Date: 11 Mar 1998 22:28:41 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: splice -- useful uses?
Message-Id: <x71zw8zixi.fsf@sysarch.com>

abigail@fnx.com (Abigail) writes:

> Andrew M. Langmead (aml@world.std.com) wrote on 1653 September 1993 in
> ++ klassa@aursgh.aur.alcatel.com (John Klassa) writes:
> ++ push @random, splice @orig, rand @orig, 1 while @orig;
> 
> I hate to see a quadratic algorithm being used a an example
> for what people use splice for if there's a linear algorithm
> doing the same.
> 
> Knuth's algorithm:
> for ($i = @arr; $i; $r = rand $i --, @arr [$r, $i] = @arr [$i, $r]) {}

i will admit your version is faster since there is no slicing, but both
algorithms are linear. unless you are counting the slice (shifting down
the array) as the quadratic behaviour.

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 11 Mar 1998 17:04:35 -0800
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: splitting by one or more spaces
Message-Id: <6e7cb3$e8k$1@halcyon.com>

[CC'd and posted]
"Oosterom" <oosterom@e-mark.nl> arranged electrons in a pattern like this:
>I am trying to extract the date from the localtime value. I have to split
>this value, but if the daynumber is smaller than 10, there are two spaces
>before this number in the localtime value. This means I have to split by
>one or more spaces. The codes below don't work:
>
>($day, $month, $daynr, $time, $year) = split (/*\s/, localtime);

Documentation for split and localtime each have good solutions to this.

Use localtime in list context instead of scalar context and it'll parse
itself (or more specifically won't waste the time to format itself 
from the list it starts with).  The documentation (perldoc -f localtime)
suggests something like:
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;

Give split no pattern or a single space as pattern and it'll split on
any-length whitespace, e.g. split(' ',scalar localtime);

Good luck!
--
Mark Rafn    dagon@halcyon.com    <http://www.halcyon.com/dagon/>   !G


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

Date: Wed, 11 Mar 1998 20:01:58 -0600
From: Jose Angel <al346873@academ01.mty.itesm.mx>
Subject: Test (ignore this message)
Message-Id: <35074215.E13054FB@academ01.mty.itesm.mx>

This is a test.

Sorry.



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

Date: Wed, 11 Mar 1998 16:21:32 -0600
From: sporty@webcreate.net (Sporty)
Subject: Testing a perl "CGI" script
Message-Id: <MPG.f70ca686281fd6c98968e@newsrv.capital.ge.com>


I would like to know if someone would be willing to 
test a perl CGI script. I have done my best to put it 
together and use it on my web page. It is a guestbook 
that will send me e-mail when someone leave a message.

My ISP has given me a cgi-bin directory on their 
server and "swears" it has the proper permissions.

What I am looking for is someone to take the two files 
I am trying to test (guestbook.html and guestbook.cgi) 
and see if they do work. If they do, then I am sure it 
is nothing wrong with my files.

I would e-mail you the two files... All I can offer in 
return is a cold beer the next time you are in 
Minneapolis.

Thank you for your time

Sporty
sporty@webcreate.net


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

Date: Thu, 12 Mar 1998 13:04:38 +1100
From: Justin Wills <justin@nectar.com.cu>
Subject: Re: Testing a perl "CGI" script
Message-Id: <350742B6.A13E0120@nectar.com.cu>

look out for cgilint.  it allows you to test your cgi scripts without
using a webserver.  all it
requires is perl

I think it was mentioned in the O'reilly CGI book.  check out their
pages and look for the source.

Sporty wrote:

> I would like to know if someone would be willing to
> test a perl CGI script. I have done my best to put it
> together and use it on my web page. It is a guestbook
> that will send me e-mail when someone leave a message.
>
> My ISP has given me a cgi-bin directory on their
> server and "swears" it has the proper permissions.
>
> What I am looking for is someone to take the two files
> I am trying to test (guestbook.html and guestbook.cgi)
> and see if they do work. If they do, then I am sure it
> is nothing wrong with my files.
>
> I would e-mail you the two files... All I can offer in
> return is a cold beer the next time you are in
> Minneapolis.
>
> Thank you for your time
>
> Sporty
> sporty@webcreate.net





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

Date: Wed, 11 Mar 1998 18:46:17 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: The -w switch (was Re: better way to do this?)
Message-Id: <35073DA7.6B605631@5sigma.com>

Ilya, that's not even close!  Not to put too keen a point on it,
but try arguing the subject without redefining terms like "assertion."

	-joseph

Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to Joseph N. Hall
> <joseph@5sigma.com>],
> who wrote in article <3500D24E.B4657F64@5sigma.com>:
> > Your users are running prototype software?
> >
> > Perl is perfectly suitable for producing finished products.  Finished
> > products don't yield assertion failures under any circumstances.
> 
> I'm using a finished product.  It is an OS.  It asserts that all the
> applications access the memory they are allowed to access only.
> 
> If this assertion fails, I get a message.

-- 
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com
     Omniscient trash / Mr. Con Antithesis / In shortest, manic!


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

Date: Wed, 11 Mar 1998 13:16:02 -0500
From: prn@bsu.edu (Paul Neubauer)
Subject: Re: Using regex to initial cap a name
Message-Id: <MPG.f709eebb6236481989686@news.bsu.edu>

In article <6e2hik$9qv$1@client2.news.psi.net>, abigail@fnx.com writes...
> Franco Finstad (ffinstad@best.com) wrote on 1652 September 1993 in
> <URL: news:3504B813.BA50CA20@best.com>:
> ++ I need to translate the string:
> ++ 
> ++     lastname, firstname
> ++ 
> ++ into:
> ++ 
> ++     Lastname, Firstname
> ++ 
> ++ I know this can be done elegantly using tr///; and s///; but I haven't
> ++ found a way.
> 
> I suggest:
> 
> tr/firstname/perlfaq 4/;

As in "How do I capitalize all the words on one line?" perhaps?  That 
would appear to be a relevant reference.  But, while you're at it, don't 
forget to check your output against:

    van Beethoven, Ludwig
    de la Madrid, Miguel
    Van Camp, Susan
    van Camp, Paul
    O'Malley, Michael
    Cabeza de Vaca, Juan
    Macdonald, Ross
    MacDonald, Larry

The point being that names are often much more complicated than simply a 
firstname and lastname.  Capitalization (like pronunciation:-) is 
extremely idiosyncratic.  Don't expect to be able to restore the 
"correct" capitalization by a simple or "elegant" rule.  A case-
insensitive database of names is too insensitive.

I don't know what Franco had in mind originally, but although prettifying 
a case-challenged database is better than nothing, it cannot be 
considered reliable.

-- 
Paul Neubauer          prn@bsu.edu
http://nova.bsuvc.bsu.edu/prn/
PGP Public Key at http://nova.bsuvc.bsu.edu/prn/key.html


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

Date: 12 Mar 1998 01:56:32 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <6e7fcg$q3n$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
:Per word.  As in: "Ja Va" => "Yes (using swedish) Go (using spanish)"
:
:I'm surprised none of the other English/Swedish/Spanish trilingual
:readers of this group said anything.

Aber auf Deutsch sagt Mann la misma cosa (o sea, "ja") que dice en el
Swedish, n'est-ce pas?  How se sabe si es aleman oder sueco dort?  :-)

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    if (instr(buf,sys_errlist[errno]))  /* you don't see this */
        --Larry Wall in eval.c from the 4.0 perl source code


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

Date: 12 Mar 1998 03:16:33 GMT
From: "Dave Roth" <rothd@xrxoxtxhx.xnxextX>
Subject: Re: Win32::AdminMisc::GetDriveSpace and Active Server Pages
Message-Id: <01bd4d65$97fbf730$0101a8c0@main2>



Creede Lambard
<$_=qq!fearless@NOSPAMio.com!;y/A-Z//d;print> wrote in
article <6dvvbp$5qf@bgtnsc02.worldnet.att.net>...
> Most likely it's something simple. I haven't checked this
(my NT system is
> at work :D), but I would guess that your Perlscript
routine is unable to
> access \\(server)\c$ properly. It's a hidden,
administrative share and not
> necessarily meant to be seen or accessed by everybody.

Very correct. Likewise it is possible that your web server
account does not have the admin permissions to access that
a default share (like \\server\c$ or \\server\admin$). 
Another issue that I have yet to find resolution to is that
under IIS 4.0 cgi scripts (including perlscript) does not
always successfull access objects accross the net via UNC's
or even mapped drives regardless of permissions.
dave
-- 
============================================================
====
Dave Roth                               ...glittering
prizes and
Roth Consulting                     endless compromises,
shatter
rxoxtxdxxrxoxtxhx.xnXeXt               the illusion of
integrity

 My email address is disguised to fool automailers. Remove
the
                      X's to send me email.
************************************************************
****
Use of  this message or  email address  for commercial 
purposes
(including "junk" mailings) is strictly prohibited and
protected
under  current  international  copyright laws  and United
States
Code, Title 47, Chapter 5, Subchapter II.

 



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

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

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