[10371] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3964 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 13 15:07:38 1998

Date: Tue, 13 Oct 98 12:00:23 -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           Tue, 13 Oct 1998     Volume: 8 Number: 3964

Today's topics:
    Re: accessing instance variables (Mark-Jason Dominus)
    Re: Alpha and MacPerl still misbehave <rootbeer@teleport.com>
    Re: Are there any "perl.newbie" group or forum? <jdporter@min.net>
    Re: Are there any "perl.newbie" group or forum? <mp@mkt2mkt.com>
    Re: Are there any "perl.newbie" group or forum? (Tad McClellan)
    Re: Are there any "perl.newbie" group or forum? <eashton@bbnplanet.com>
    Re: Are there any "perl.newbie" group or forum? (Kevin Reid)
    Re: Best way to absolutize URL's in HTML, trying to avo (Abigail)
    Re: Domain/mapping//pointer <rootbeer@teleport.com>
    Re: file modification (Brand Hilton)
    Re: Graphic Date <mark@uninetwork.com>
    Re: Mail on NT scott@softbase.com
    Re: Perl book or WWW Recources <mp@mkt2mkt.com>
    Re: Perl Cookbook - is this the best perl book? <anthony.clark@adv.sonybpe.com>
    Re: Perl Cookbook - is this the best perl book? (Mike Stok)
    Re: Perl Cookbook - is this the best perl book? (Karlon West)
        Problems compiling Perl 5.005_02 under Dynix/PTX 4.0 V4 <hd-fxsts@liii.com>
        Question about search engines <mp@mkt2mkt.com>
    Re: Question about search engines <uri@camel.fastserv.com>
    Re: sorting hack (Larry Rosler)
    Re: sorting hack (Larry Rosler)
        sql <ez062634@mailbox.ucdavis.edu>
    Re: sql <rootbeer@teleport.com>
    Re: SSL support for perl server? <estabroo@ispn.com>
    Re: unidirectional pipe into interactive program (passw (Kevin Buhr)
        Unix Perl vs. Unix Perl? (Chilton Webb)
    Re: want to leave tcl for perl lvirden@cas.org
    Re: want to leave tcl for perl (Ilya Zakharevich)
    Re: which chars to escape in reg.exp? (Abigail)
    Re: which chars to escape in reg.exp? <dgris@perrin.dimensional.com>
    Re: which chars to escape in reg.exp? (Tad McClellan)
    Re: which chars to escape in reg.exp? (Ilya Zakharevich)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 13 Oct 1998 13:41:44 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: accessing instance variables
Message-Id: <7003co$147$1@monet.op.net>

In article <6vvu98$u1n$1@nnrp1.dejanews.com>,  <reesor@peoplescape.com> wrote:
>I'm positive I must be doing something wrong here, but I sure don't
> see it. 

You showed the method definitions, and they have comments that say
what they do when you run some test case, but you didn't include the
test case in your article!

># I have a class like this:
>
>sub new {
> ...
> self->{foo} = NULL;
>}

>sub bar
>{
> my($self) = shift;
>
> my($firstTry) = $self->{foo};
> print "firstTry: $firstTry\n"; # prints NULL

Well, of course----you *set* it to be NULL.

And if you did something somewhere else that should have set it to be
something else, you didn't show it in your article.

># It seems to me that the bar method should be able to access instance
># variable foo directly and not only through the access method.

It can and it does.

># Thanks again for any ideas!!

Try using the debugger.  Then you'll see what is happening and in what order.



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

Date: Tue, 13 Oct 1998 18:46:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Alpha and MacPerl still misbehave
Message-Id: <Pine.GSO.4.02A.9810131144470.1979-100000@user2.teleport.com>

On 13 Oct 1998, Richard S. Holmes wrote:

> The file has Mac linebreaks. 

That's what Alpha claims; could it be lying? Either it is or MacPerl is,
I'd say. If you can use Macsbug, you can find out, but using Macsbug is
way out of the scope of this newsgroup. Good luck with it!

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



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

Date: Tue, 13 Oct 1998 13:04:16 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <3623880F.269534A6@min.net>

Mike West wrote:
> 
> In article <Pine.GSO.3.92.981013114406.12706g-100000@edb>
>   Casper Kvan Clausen, ckc@dmi.dk writes:
> 
> >ML, for instance, is very clear and suitable for learning programming.
> 
> "ML" ?  Microsoft Lingo ?  Multi Level? Mini Lisp ?  Macho Language ?
> 
> Must be a TLA.  (two letter acronym, not to be confused with a
> TLA, a three letter acronym...)

"The programming language ML was originally designed for use as the
metalanguage in the Logic for Computable Functions (LCF) verification
system.... ML is a strongly typed, functional programming language..."
ML Primer, by Ryan Stansifer; Prentice-Hall, 1992.

Standard ML -- Project Fox at CMU:
	http://foxnet.cs.cmu.edu/sml.html

Standard ML of New Jersey:
	http://cm.bell-labs.com/cm/cs/what/smlnj/

CAML:
	http://caml.inria.fr/

OCAML, an object-oriented variant:
	http://pauillac.inria.fr/ocaml/

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Tue, 13 Oct 1998 10:08:54 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <36239733.483787E1@mkt2mkt.com>

> The Llama book is about as simple as it gets. 

This is the problem, if you haven't figured it out, oh wise one!

> Besides, in the big picture, programming is no different than any other 
> discipline. 

I disagree.  Rarely is it that lovers of a discipline are so protective to newcomers.

Rarely do they swat the novices round the head neck and shoulders just because
they can.

Maybe if you were joining an abbey during the middle ages, but that's another kind
of discipline that I care not for.

> How did you learn anything that you know which you taught 
> yourself? 

By doing it, and not being afraid to experiment, which means to fail.  I
by my own doing am not afraid to be a failed programmer.  It's how I learn to
good at anything, since you can only get better from there.

I took years of piano lessons but it was my own interest in
> the music which made the difference between mediocre and concert level. 

Are you a concert pianist?

>The book is but one tool among many which you can use to teach yourself.
> 

Duh.  If you've heard of user-interface, then you should understand 
to what topic I am addressing.

> > What books would you recommend for intelligent independently studious
> > non-programming programmers??
> 
> Intelligent independently studious people never need to ask that
> question.

I think you mean intelligent independently studious people who are full of themselves
need never ask that question.

------
madame philosophe 

"I am not a troll!"

- Famous last words before
the
guillotine of comp.lang.perl.misc

She's here to save the world from herself...


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

Date: Tue, 13 Oct 1998 11:52:19 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <3g0007.kta.ln@flash.net>

Tad McClellan (tadmc@flash.net) wrote:

:    The demand is there despite it being a bad thing.


   It now occurs to me that Bill got rich from such a thing...  ;-)


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


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

Date: Tue, 13 Oct 1998 17:49:08 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <36239014.CBF04C54@bbnplanet.com>

madame philosophe wrote:

> This is the problem, if you haven't figured it out, oh wise one!

By simple, I mean as informative and as useful in as few pages as
needed. There is a 'Perl5 for Dummies' if you need it.

> I disagree.  Rarely is it that lovers of a discipline are so protective to 
> newcomers.

*bzzzzt* Like anything, including life, there is a caste and a status.
Ever try being the middle-class girl with a non-pedigreed horse in
competitive equestrian sports? Vicious. Makes these jerky-boyz look like
a walk in the park. 

> Rarely do they swat the novices round the head neck and shoulders just because
> they can.

You must live a fairly sheltered life.

> Maybe if you were joining an abbey during the middle ages, but that's another kind
> of discipline that I care not for.

Nuns have the same kind of discipline with the exception perhaps of
forgoing the carnal. Admirable.

> By doing it, and not being afraid to experiment, which means to fail.  I
> by my own doing am not afraid to be a failed programmer.  It's how I learn to
> good at anything, since you can only get better from there.

To try is not to fail, you succeed by your very doing. What is it to
'win'? Learning anything is a win no matter the relative proficiency. 

> Are you a concert pianist?

Competed for a seat on the same symphony my sister played for. Lost.
Became a chemist instead with a penchant for Russian Romantics and Jazz
:) I do a wicked Tony Bennett impression at parties with a piano. 

> Duh.  If you've heard of user-interface, then you should understand
> to what topic I am addressing.

Well, duh, if you were reading, my implicit point here was, why are you
looking for something to speak the answer to you? There is nothing in
this world that will teach you anything if you are not willing to put a
bit of yourself into it. 'you can lead a horse to water but you can't
make him drink.' Make your own interface. Bend a spoon with your mind.
:)

> I think you mean intelligent independently studious people who are full of 
> themselves need never ask that question.

No. Your sentence was an oxymoron. Intelligent. _Independently_
studious. These are not the types of people who ask a million people who
has the answer. Sometimes they create their own. And most of them are
full of themselves and much more.

> "I am not a troll!"

You are or I'm not Martha Stewart. :)

e.


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

Date: Tue, 13 Oct 1998 13:59:30 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <1dgqya1.151mx2bp5l112N@slip166-72-108-149.ny.us.ibm.net>

I R A Aggie <fl_aggie@thepentagon.com> wrote:

> <snip "160-line dissertation on why questions go unanswered">

I wish everybody had to read that before they could post to clp.misc.
clp.moderated had a good idea there (that people have to register before
they can post, and the registration form has lots of useful information
about where to find help for Perl). Would it be possible to do something
similar with clp.misc (not moderated, but people have to register before
posting)?

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 13 Oct 1998 17:43:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Best way to absolutize URL's in HTML, trying to avoid HTML::Parser
Message-Id: <7003fo$7gu$1@client3.news.psi.net>

Anmar To (amt@nuteknet.com) wrote on MDCCCLXIX September MCMXCIII in
<URL:news:36229824.5092@nuteknet.com>:
++ Hi -
++ 
++ I've looked for a module that does this on CPAN and
++ read a couple of FAQs and haven't found the answer
++ I'm looking for.  I'm relatively new to Perl, though,
++ so I could be missing something obvious.
++ 
++ 
++ I considered using the HTML::Parser module, but
++ I'd like something that executes fairly fast, since
++ this will be part of a CGI program.  I've been trying
++ to construct a great big regular expression, but with
++ not much success.

What makes you think a great big regular expression from someone who's
relatively new to Perl is faster than HTML::Parser? 

++ I've also noticed that my current, fairly complex,
++ regular expression takes a while to finish.  Is there
++ any way around this?  I'm only testing it with a 63-line
++ file.

Yes. Don't use a fairly complex regular expression! 

Why is that every one and its uncle want to tackle HTML parsing problems
with huge big regexs that won't work for most non trivial cases instead
of just parsing it? There's even a module on CPAN that does the parsing
for you!

++ Any suggestions?  A different approach? Is HTML::Parser really that
++ slow? Anyone used HTML::SimpleParse?

You are complaining about your regexs being slow. That means, you've tried
it. Have you tried using HTML::Parser? Is it slow?



Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


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

Date: Tue, 13 Oct 1998 18:53:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Domain/mapping//pointer
Message-Id: <Pine.GSO.4.02A.9810131153260.1979-100000@user2.teleport.com>

On Tue, 13 Oct 1998, Rob wrote:

> does such a script exist in pearl and where can locate it??

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

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



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

Date: 13 Oct 1998 18:14:57 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: file modification
Message-Id: <7005b1$7p213@mercury.adc.com>

In article <36238284.AABB74FF@tinet.ie>,
Edouard Ouin  <Edouard.Ouin@tinet.ie> wrote:
>hi,
>
>I need to known what's the simplest way to modify the content of  file,
>ie modify a line, delete a line.

man perlfaq5
/How do I change one line in a file


-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: Tue, 13 Oct 1998 13:05:10 -0400
From: Mark Cain <mark@uninetwork.com>
To: Billy Jacobs <nomail@netscape.com>
Subject: Re: Graphic Date
Message-Id: <36238846.A786017E@uninetwork.com>

Here is the code that I use to take a string (in this case a first and
last name with an optional initial) and convert that into a graphic
design.

I have in the /images directory files such as:
a.gif
b.gif
c.gif
etc... and even
period.gif


# make the graphic name
# bring the $name down to lower case
$graphicname = lc($name);

# swap each "letter" for "<IMG SRC="../images/letter.gif">"
$graphicname =~ s/([a-z])/<IMG SRC="\.\.\/images\/\1\.gif">/g;

# swap each "period" for "<IMG SRC="../images/period.gif">"
$graphicname =~ s/>\./><IMG SRC="\.\.\/images\/period.gif">/g;

# swap each "space" for two forced spaces
$graphicname =~ s/> />&nbsp;&nbsp;/g;

Then print the variable $graphicname out into a html document.

This should get you goin'.

Mark

Billy Jacobs wrote:

> Hey all--
>
> I am looking for a simple script (for you guys), which would allow a
> webpage to dynamically display the date by using existing graphics on
> a server.  For example, I would like to have a graphic for each day of
> the week (monday.gif, tuesday.gif...etc), as well as each month
> (january.gif...), as well as two digit day (1.gif...)(1.gif..), and
> finally year (1998.gif, 1999.gif...).
>
> I have seen plenty of scripts around that will display the current
> date in this format, however, they only display text.  What I would
> like to do sounds relatively easy -- assign a graphic to the text
> output of each field, however, since I don't know perl, I can't figure
> it out.  I have tried to modify existing scripts to no avail.
>
> If anyone has seen a script like this, or knows how to create one,
> could they be so kind as to help a newbie out?  Any help would be
> seriously appreciated!!!!
>
> Billy
>
> billyj3 at mindless.com



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

Date: 13 Oct 1998 17:34:10 GMT
From: scott@softbase.com
Subject: Re: Mail on NT
Message-Id: <36238f12.0@news.new-era.net>

Mike Pritchard (mikep@5circles.com) wrote:

> So how do I use SMTP to talk to Microsoft Mail post offices?  (pre
> Exchange?)

If you're using pre-Exchange post offices, I think whatever you
are doing is pretty much doomed to failure anyway :) Why
not put real Internet mail on the network?

Does Microsoft even support the old post offices any longer?

Scott


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

Date: Tue, 13 Oct 1998 10:20:37 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Perl book or WWW Recources
Message-Id: <362399F0.4C1411A2@mkt2mkt.com>

Hey Curious George,

Funny you should ask that question.... Keep your eyes peeled to the thread
Are there any perl.newbie group or forum. It's just about to size up that very question!

btw try just doing a search on Perl Tutorials, there are some out there on the
web, they
not are not great, but it's something.

The Waite Group has an online tutorial too.  check out http://www.waite.com/ezone
I think that's the url....

Also if you are interested in Perl for CGI then you could check out (aside
from searching
Perl and CGI) Lincoln Stein's book, but it could throw you for a loop if you
don't know
any Perl at all.

Given that, you will need to prepare yourself for a lot of flaming as there
seems to be low
tolerance here for newbies. That is if you post anything at all.

good luck!

mp

George wrote:
> 
> I have read books from our local library about perl. They are geared
> for people who have experience in programming in other languages and
> certain assumptions are made.
> Could someone please suggest a good book that explains from the ground
> up OR are there recources on the www that I could access and study?
> Thank you
> george9684@my-dejanews.com

-- 
------
madame philosophe 

"I am not a troll!"

- Famous last words before
the
guillotine of comp.lang.perl.misc

She's here to save the world from herself...


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

Date: Tue, 13 Oct 1998 15:01:32 +0100
From: Anthony Clark <anthony.clark@adv.sonybpe.com>
To: lqyrms@nottingham.ac.uk
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <36235D50.1E46F15C@adv.sonybpe.com>

> Could anybody who has read the Perl Cookbook please tell me if this is the
> best perl book to get.

I'm no Perl expert, but I found this book invaluable.  It has many examples that
are spot on to what I wanted to do.  However, I was disappointed it didn't answer
this:

foreach $item ( @array )
{
    # delete the current $item from the @array if it matches a pattern
}

How the hell do I do this?

Um, I digress.  Buy the Perl cookbook, but I would flick through it first -
perhaps wait and see what the Perl in a nutshell book is like.

Did you want a specific yes or no? ;-)
--
/*
 * Anthony Clark,
 * Broadcast R&D,
 * Sony Broadcast and Professional Europe,
 * Jays Close, Viables, Basingstoke, UK.
 * RG22 4SB
 *
 * Tel: (+44) (1256) 483444 (direct)
 * Fax: (+44) (1256) 810950
 */




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

Date: 13 Oct 1998 17:24:11 GMT
From: mike@mike.stok.co.uk (Mike Stok)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <7002br$jng@news-central.tiac.net>

In article <36235D50.1E46F15C@adv.sonybpe.com>,
Anthony Clark  <anthony.clark@adv.sonybpe.com> wrote:

>foreach $item ( @array )
>{
>    # delete the current $item from the @array if it matches a pattern
>}
>
>How the hell do I do this?

for ($index = $#array; $index >= $[; $index--) {
    if ($item should be deleted) {
        splice @array, $index, 1;
    }
}

is one way to do it.

Maybe not the best, but it does avoid cutting the ground out from beneath
yourself.  Whether it's OK depends on the side of your data set, how many
elements get removed and where they are in the array...

Hope this helps,

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: 13 Oct 1998 18:16:17 GMT
From: karlon@bnr.ca (Karlon West)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <7005dh$dtf@crchh14.us.nortel.com>

Mike Stok (mike@mike.stok.co.uk) wrote:
> In article <36235D50.1E46F15C@adv.sonybpe.com>,
> Anthony Clark  <anthony.clark@adv.sonybpe.com> wrote:

> >foreach $item ( @array )
> >{
> >    # delete the current $item from the @array if it matches a pattern
> >}
> >
> >How the hell do I do this?

> for ($index = $#array; $index >= $[; $index--) {
>     if ($item should be deleted) {
>         splice @array, $index, 1;
>     }
> }

I thought this was what grep was for:
========
#!/usr/bin/perl -w

@array = qw(one two three 4 five);

$item_to_be_deleted='\d'; # delete digit entries

print "before: @array\n";

@array = grep !/$item_to_be_deleted/, @array;

print "after: @array\n";
========

Karlon


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

Date: Tue, 13 Oct 1998 14:13:13 -0400
From: Bruce Schuck <hd-fxsts@liii.com>
Subject: Problems compiling Perl 5.005_02 under Dynix/PTX 4.0 V4.2.3
Message-Id: <36239839.413D36E6@liii.com>

Perhaps someone else had tried this and came up with a solution
already.  I've been knocking my brains for the past day.

I use the C compiler supplied by Sequent.  I use all the defaults
given by Configure except 'prefix' which I use as /usr/local/perl. 
And I added "-lseq" to the list of libraries to link.  Got the same
error without the "-lseq".  LD_LIBRARY_PATH is set properly.  As well
as the extra cc flags needed to sockets to work properly.

While running make test I get one failed test.

It is in lib/io_sel.t

While running "./perl harness" from the "./t" directory I get:

lib/io_sel..........Can't use an undefined value as a symbol reference
at lib/io_sel.t line 71.
dubious
        Test returned status 9 (wstat 2304, 0x900)
DIED. FAILED tests 11-21
        Failed 11/21 tests, 47.62% okay

It looks like something to do with select(3)?  Perhaps I should try to
use perlio?

Any help is greatly appreciated.

Bruce Schuck


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

Date: Tue, 13 Oct 1998 10:31:58 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Question about search engines
Message-Id: <36239C98.5C87DF6B@mkt2mkt.com>

Do the commercial SE's tend to be written in Perl?
I would think so but would rather hear it from the masses.


------
madame philosophe 

"I am not a troll!"

- Famous last words before
the
guillotine of comp.lang.perl.misc

She's here to save the world from herself...


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

Date: 13 Oct 1998 14:32:12 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: Question about search engines
Message-Id: <sarr9wcqpn7.fsf@camel.fastserv.com>

>>>>> "mp" == madame philosophe <mp@mkt2mkt.com> writes:

  mp> Do the commercial SE's tend to be written in Perl?  I would think
  mp> so but would rather hear it from the masses.

what do you mean by commercial? one you have to pay to use or pay to
own? and do you know that search engine systems tend to have 3 major
components which can be very isolated and developed and written in
different languages and on different systems. (the 3 components are the
crawler, the indexer and the search engine itself).

from my own experience (having written the crawler for a major search engine
system in C) perl is a poor choice for efficiency reasons. there are many
smaller systems using perl since it is easier to develop in but it
doesn't scale well up to the GB's a day needed to crawl the entire web.

and who are you calling masses?

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Tue, 13 Oct 1998 11:46:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting hack
Message-Id: <MPG.108d3fe2ab939406989803@nntp.hpl.hp.com>

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

In article <6vthdu$m3e$1@client3.news.psi.net> on 12 Oct 1998 18:22:54 
GMT, Abigail <abigail@fnx.com> says...
> Xah (xah@best.com) wrote on MDCCCLXVII September MCMXCIII in
> <URL:news:6vqlr2$aga$1@nntp2.ba.best.com>:
> ++ 
> ++ I have an array of arrays of the form [[a1,a2,...],[b1,b2,...],...]. I want
> ++ to sort them first by their digits starting from the left, then by their
> ++ length. For example, here's a sorted result
> ++ [[0], [1], [1, 0], [1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2], [1, 2,
> ++ 0], [1, 2, 1], [1, 2, 2], [2], [2, 0], [2, 1], [2, 1, 0], [2, 1, 1], [2, 1,
> ++ 2], [2, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]
> ++ 
> ++ [1,1,2] comes before [1,2] because the second digit of first is smaller.
> ++ [1, 2] come before [1, 2, 0] because even their index comparison is neutral,
> ++ but the first has shorter length.
> ++ 
> ++ How would one best implement this in Perl? I couldn't figure out a way to
> ++ avoid a loop in the sort comparison subroutine. (I'm interested in speed
> ++ here.) This will be a function. The argument is not known until runtime.
> 
> You will always have a loop in the comparison routine; either directly
> in your program, or somewhere behind the scenes.

"Always" is a rather strong statement.  Below is the code I posted 
yesterday, modified to deal with Xah's unreasonable requirement that the 
input numbers (all non-negative integers) can be of arbitrary length.  I 
cannot find a loop in the comparison routine; either directly in my 
program, or somewhere behind the scenes.

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

my @in =
([0], [1], [1, 0], [1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2],
[1, 2, 0], [1, 2, 1], [1, 2, 2], [2], [2, 0], [2, 1], [2, 1, 0],
[2, 1, 1], [2, 1, 2], [2, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]);

my $max = 30; # Or compute it by scanning the data.

my @out = map $_->[0] => sort { $a->[1] cmp $b->[1] }
    map { [ $_, sprintf "%${max}s" x @$_ => @$_ ] } @in;

print '(';
{
    local ($,, $") = (', ', ', ');
    print map "[@$_]" => @out;
}
print ")\n"; 
__END__

If the data are really enormous, they must be input as strings, e.g.,

my @in = ([qw(5000000000000000000000)],[qw(1000000000000000000000 2)]);

to prevent immediate conversion to floating-point, which will not sort 
correctly and might lose precision.

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


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

Date: Tue, 13 Oct 1998 11:50:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting hack
Message-Id: <MPG.108d40d1bb3f47e9989804@nntp.hpl.hp.com>

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

In article <36238032.4C56F8EB@min.net> on Tue, 13 Oct 1998 12:30:42 -
0400, John Porter <jdporter@min.net> says...
> Xah wrote:
> > 
> > I just noted that this solution fails when the numbers are greater
> > than 'long'. For example,
> >   my $ref = [[5000000000000000000000],[1000000000000000000000,2]];
> >   print Dumper(IndexSetSort2($ref,1,1,1));
> > will print "$VAR1 = [['5e+21'],['1e+21',2]];"
> 
> Of course.  Perl treats numbers as floating-point whenever integers
> aren't capable of holding the value, e.g. when a division has a
> remainder.

In a response to Abigail, I just posted a comment on this point.  The 
input must be presented as strings to prevent conversion to floating 
point, and then sorted as strings as I showed there.

my $ref = [[qw(5000000000000000000000)],[qw(1000000000000000000000 2)]];

The issue that Xah continues to ignore is that it is not necessary to pad 
the comparison strings to equal length as determined by the length of the 
largest sub-array.

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


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

Date: Tue, 13 Oct 1998 09:44:26 -0700
From: Michael Nguyen <ez062634@mailbox.ucdavis.edu>
Subject: sql
Message-Id: <Pine.GSO.4.04.9810130930260.25100-100000@catbert.ucdavis.edu>

Does anybody know of a good resource to learn how to use SQL and mSQL?
Books? Websites? Newgroups?

Thanks





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

Date: Tue, 13 Oct 1998 18:52:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: sql
Message-Id: <Pine.GSO.4.02A.9810131149521.1979-100000@user2.teleport.com>

On Tue, 13 Oct 1998, Michael Nguyen wrote:

> Does anybody know of a good resource to learn how to use SQL and mSQL?
> Books? Websites? Newgroups?

Yes, those are the ones you should use (instead of a Perl newsgroup) to
learn how to use SQL and mSQL. If you're not sure where to start, use your
favorite search engine to find some resources on the web. Good luck!

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



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

Date: Tue, 13 Oct 1998 13:58:57 -0500
From: Eric Estabrooks <estabroo@ispn.com>
Subject: Re: SSL support for perl server?
Message-Id: <3623A2F1.327217A8@ispn.com>

plambert$1@plambert.org wrote:
> 
> I've written a simple, single-threaded server using perl5, a number
> of useful books, and a lot of trial and error.  It's not a web server,
> but instead used for some internal company work.
> 
> Currently, it just listens on a socket, sends data across, etc.  I'd
> like to allow some sort of encryption, and SSL sounds like a nice idea.
> However, I don't know what I need to do to support it.
> 
> Specifically, has anyone written any kind of a server which accepts
> both SSL and cleartext connections?  (This would be necessary for a
> while until all the clients can be updated...)
> 
> More importantly, how much work is it to implement?  I just have a
> select call right now looking at all the open sockets, and then deal
> with each one in sequence when data is available.  How difficult would
> it be to add SSL support to this sort of server?
> 
> Many thanks to anyone who can give me some pointers.  I've read the
> SSLeay FAQ and the docs for Net::SSLeay, but I'm not familiar enough
> with the SSL protocol to understand exactly what would be necessary
> for me to get this to work.
> 
> My intention is not to provide financial-network-level security.  The
> application is not nearly that important.  The primary goal is to
> prevent casual packet sniffing to see the traffic.  I've even considered
> using simple obscurement (XOR or something similar), although I'd like
> something a little stronger than that...
> 
> --Paul L.
> 
> --
> And how do you know what you need to know?  Life has certain,
> shall we say, boundary problems....  -- Todd Michel McComb


I have a module (it will be available from CPAN soon) that does a fast
encryption using MD5 or SHA.  Basically it implements a chaining block
cipher using the hash as the xor generator.  This is the same crypt used
by radius to hide password information.

It is used like this.  The client and server have a shared secret.  The
client sends information to the server by generating a random number or
key (can be alphanumeric) and sends it to the server(plaintext).  It
then feeds that same key with the shared secret to the module and then
feed each line you want to encrypt to the module and it spits back the
encrypted text (which you should base64 encode) that is passed to the
server.  The server just reverses that process.  If you have well chosen
secret keys and do not repeat the random key then the algorithm is as
secure as the underlying hash.

If you are interested I can send you the HCE::MD5 module (on CPAN it'll
probably be called Crypt::HCE_MD5) along with a client and server
examples.

Eric
 estabroo@ispn.com

-- 
Change is inevitable, except from a vending machine.
 -- Author Unknown --


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

Date: 13 Oct 1998 13:07:01 -0500
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: unidirectional pipe into interactive program (passwd)
Message-Id: <vban2705oai.fsf@mozart.stat.wisc.edu>

"Mikkel K." <mtk@egmont-kol.dk> writes:
> 
> I need to pipe a string into an interactive program, and I thought that
> something like this could do it:

Typically, programs that prompt for a password will open "/dev/tty"
(an alias for the process's controlling terminal) and take user input
from there.  I assume "smbpasswd" is one of these programs, so no
matter what you try to do with "smbpasswd"'s standard input, it'll
still try to prompt you at the keyboard.

> I found Expect.pm on CPAN, but partly I'm lazy, and partly I need some
> portability for my program, and I (think that I ;-) don't need the
> output from my passwd program.

"Expect.pm" does magical things to get the controlling terminal right,
so it's your best bet for getting this working.

Kevin <buhr@stat.wisc.edu>


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

Date: Tue, 13 Oct 1998 12:40:17 -0600
From: chilton@tca.net (Chilton Webb)
Subject: Unix Perl vs. Unix Perl?
Message-Id: <chilton-1310981240170001@tl2-082.tca.net>

I've lately come to find several differences between the Perl on my new
server and the Perl on the old server. But I could just be *wrong*. Both
of them have the same version (5.002) but one absolutely hates the
following script. Please tell me if I'm just stoopid:

#!/usr/bin/perl
%$fillings = ('babeName', 'Deirdre', 'count', '3');
$text = "I went out with <!--babeName--> <!--count--> times";
$text =~ s/ <!-- ( .*? ) -->/ $fillings->{$1}/gsex;
print "Content-type: text/html\n\n\n\n";
print "$text";

Any idea why? Specifically, it hates:
1. %$fillings
2. (.*?) 
3. the 'gsex' at the end of the s/

These three problems return core dumps. (geez).

Also, these are taken straight from several Perl books, and this script
works great in MacPerl.

Any ideas? I've never seen anything like this.

-Chilton


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

Date: 13 Oct 1998 17:59:06 GMT
From: lvirden@cas.org
Subject: Re: want to leave tcl for perl
Message-Id: <7004da$pes$1@srv38s4u.cas.org>


According to Larry Daffner  <ldaffner@rsn.hp.com>:
:The fileevent line is Tk, not tcl, so you can just translate it
:directly to perl (I'll assume you're using Tk):

Actually, fileevent is tcl, not just tk.



-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.purl.org/NET/lvirden/> |     only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: 13 Oct 1998 18:08:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: want to leave tcl for perl
Message-Id: <7004vj$h6$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<lvirden@cas.org>],
who wrote in article <7004da$pes$1@srv38s4u.cas.org>:
> 
> According to Larry Daffner  <ldaffner@rsn.hp.com>:
> :The fileevent line is Tk, not tcl, so you can just translate it
> :directly to perl (I'll assume you're using Tk):
> 
> Actually, fileevent is tcl, not just tk.

You are mixing tk and Tk ;-).  In the tcl/tk combinations file events
are in tcl part.  In Perl/Tk combination file events are in the Tk
part.

The TCL situation is better, but we hope to fix this one moment or
other  ;-).

Ilya


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

Date: 13 Oct 1998 16:53:34 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: which chars to escape in reg.exp?
Message-Id: <7000ie$6p4$1@client3.news.psi.net>

Daniel Grisinger (dgris@perrin.dimensional.com) wrote on MDCCCLXIX
September MCMXCIII in <URL:news:m3pvbwjzgk.fsf@perrin.dimensional.com>:
++ 
++ I can't get @[ to interpolate, though, so both of your examples
++ above should be fine.


To interpolate @[, use /@{"["}/



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Tue, 13 Oct 1998 17:12:05 GMT
From: Daniel Grisinger <dgris@perrin.dimensional.com>
Subject: Re: which chars to escape in reg.exp?
Message-Id: <m3emscjsvy.fsf@perrin.dimensional.com>

abigail@fnx.com (Abigail) writes:

> To interpolate @[, use /@{"["}/

Thanks, Abigail :-).

What I meant was, I can't get @[ to interpolate without explicitly
disambiguating it as Abigail shows.

This surprised me as I thought that variable interpolation was the
first thing that happened when a regular expression is constructed.
I had thought that @[ would interpolate automatically before it
could be construed as the start of a character class.  I was wrong.

dgris
-- 
Daniel Grisinger          dgris@perrin.dimensional.com
`By about halfway through I was beginning to guess the 
ending, but it still kind of surprised me.'
      David Hatunen, talking about the movie Titanic


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

Date: Tue, 13 Oct 1998 11:58:00 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: which chars to escape in reg.exp?
Message-Id: <oq0007.kta.ln@flash.net>

M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: In article <g90uv6.7f6.ln@flash.net>, Tad McClellan <tadmc@flash.net> wrote:
: >   "character classes" are a little language within the larger
: >   regex language.
: >
: >   Within char classes there are very few metachars.
: >
: >   Only four, I think. Someone jump in if I missed any:
: >
: >   1) ^ (caret) is meta only if it is first in the char class
: >
: >   2) - (hyphen) is meta unless it is last in the char class
:                                        ^^^^
:                                   first or last


   Right.

   I knew when I was typing it in that I'd make a mistake somewhere.

   But it needed to be said, so I took a shot at it   ;-)


: >   3) ] (closing square bracket) is meta unless it is first in
: >        the char class
: >
: >   4) \ (backslash) is always meta

:     5) $ and @ introduce variable interpolation.


   I left that one off on purpose, because it is not part of the
   "language within a language" (ie. char classes).

   It is a wider Perl concept the reaches inside the char class.

   Similarly, I made no mention of the backwack char class 
   shorthands either.
   


   Sounds like a good justification anyway...      


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


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

Date: 13 Oct 1998 18:02:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: which chars to escape in reg.exp?
Message-Id: <7004jq$4d$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Daniel Grisinger 
<dgris@perrin.dimensional.com>],
who wrote in article <m3emscjsvy.fsf@perrin.dimensional.com>:
> What I meant was, I can't get @[ to interpolate without explicitly
> disambiguating it as Abigail shows.
> 
> This surprised me as I thought that variable interpolation was the
> first thing that happened when a regular expression is constructed.
> I had thought that @[ would interpolate automatically before it
> could be construed as the start of a character class.  I was wrong.

See the thread on "jumping into your face".  

Perl tries to be smart, and DWYM.  In particular, you can never
predict how a complicated RE is going to be parsed, since perl
considers several different variants, and chooses one basing on
weights assigned by unintellegible algorithms.

Ilya


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

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

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