[25593] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7837 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 27 21:05:54 2005

Date: Sun, 27 Feb 2005 18:05:15 -0800 (PST)
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, 27 Feb 2005     Volume: 10 Number: 7837

Today's topics:
    Re: Do sparse arrays take up full memory? <giblin@panix.com>
        format directory structure in html: is there a module ioneabu@yahoo.com
    Re: format directory structure in html: is there a modu <see_sig@invalid>
    Re: format directory structure in html: is there a modu <tadmc@augustmail.com>
    Re: format directory structure in html: is there a modu ioneabu@yahoo.com
    Re: How to decode this unicode-hex string <sun_tong@users.sourceforge.net>
    Re: How to decode this unicode-hex string <flavell@ph.gla.ac.uk>
    Re: maximum size of a hash table (Anno Siegel)
    Re: OOP Tutorial (Anno Siegel)
    Re: OOP Tutorial <abigail@abigail.nl>
    Re: OOP Tutorial <lesliev@NOSPAMicoc.co.za>
    Re: OOP Tutorial (Anno Siegel)
    Re: OOP Tutorial <abigail@abigail.nl>
    Re: Pure Perl OpenSSL Library <No_4@dsl.pipex.com>
    Re: sequences of numbers <abigail@abigail.nl>
    Re: sequences of numbers (Anno Siegel)
    Re: The meaning of @ <newspost@kohombanDELETE.net>
    Re: Wide character notation, was Re: How to NOT use utf <flavell@ph.gla.ac.uk>
    Re: Wide character notation, was Re: How to NOT use utf <flavell@ph.gla.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Feb 2005 14:33:54 -0800
From: "Ian" <giblin@panix.com>
Subject: Re: Do sparse arrays take up full memory?
Message-Id: <1109543634.861560.20070@z14g2000cwz.googlegroups.com>

OK, thanks for the answers. I was hoping to use arrays for speed in
looking up dated values, so there's still potential to use it as long
as I keep my known dates within some sensible boundaries (e.g. 20000101
and above, and just subtract 20000101 from the integer date each time).

Thanks
Ian.



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

Date: 27 Feb 2005 11:21:23 -0800
From: ioneabu@yahoo.com
Subject: format directory structure in html: is there a module
Message-Id: <1109532082.991177.103170@z14g2000cwz.googlegroups.com>

hi!

Is there a module or script that will take a directory name as an
argument and produce nicely formatted HTML to display the entire
directory tree?

I was going to write one, which should not be too hard, but I thought
I'd ask as to not re-invent.

Thanks!

wana



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

Date: Sun, 27 Feb 2005 15:33:59 -0500
From: Bob Walton <see_sig@invalid>
Subject: Re: format directory structure in html: is there a module
Message-Id: <42223005_2@127.0.0.1>

ioneabu@yahoo.com wrote:
 ...
> Is there a module or script that will take a directory name as an
> argument and produce nicely formatted HTML to display the entire
> directory tree?
> 
> I was going to write one, which should not be too hard, but I thought
> I'd ask as to not re-invent.
 ...
> wana
> 

Maybe one of the 6000+ modules on CPAN would do the trick:

http://www.perl.com/CPAN/

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


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

Date: Sun, 27 Feb 2005 17:51:58 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: format directory structure in html: is there a module
Message-Id: <slrnd24n8u.i8r.tadmc@magna.augustmail.com>

ioneabu@yahoo.com <ioneabu@yahoo.com> wrote:

> Is there a module or script that will take a directory name as an
> argument and produce nicely formatted HTML to display the entire
> directory tree?


Take this [1]:

   find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,|  ,g'

and modify it to generate HTML instead.  :-)



[1] Message-ID: <5sm1ka$gmg@shoga.wwa.com>

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


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

Date: 27 Feb 2005 17:56:00 -0800
From: ioneabu@yahoo.com
Subject: Re: format directory structure in html: is there a module
Message-Id: <1109555759.969631.298300@f14g2000cwb.googlegroups.com>


Tad McClellan wrote:
> ioneabu@yahoo.com <ioneabu@yahoo.com> wrote:
>
> > Is there a module or script that will take a directory name as an
> > argument and produce nicely formatted HTML to display the entire
> > directory tree?
>
>
> Take this [1]:
>
>    find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,|
,g'
>
> and modify it to generate HTML instead.  :-)
>
>
>
> [1] Message-ID: <5sm1ka$gmg@shoga.wwa.com>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

Awsome! Incredible!  I am running it right now on my Mac.

To anyone looking to hire this man, he's clearly the best for the job.

Thank you, thank you, thank you, I love it!

wana



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

Date: Sun, 27 Feb 2005 14:44:34 -0500
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Re: How to decode this unicode-hex string
Message-Id: <pan.2005.02.27.19.44.34.17212@users.sourceforge.net>

On Fri, 25 Feb 2005 21:42:38 +0000, Alan J. Flavell wrote:

>> Any way, I figured out a way to do it, without any the 
>> aforementioned unicode packages.
> 
> But you're not going to tell us what it is?

Well, it actually has nothing to do with unicode. Here is what I did to
decode such string:

perl -pe 's / \\u([0-9a-f]+) / chr(hex($1)) /giex;' 2>/dev/null;


-- 
Tong (remove underscore(s) to reply)
  *niX Power Tools Project: http://xpt.sourceforge.net/
  - All free contribution & collection


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

Date: Mon, 28 Feb 2005 00:41:14 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: How to decode this unicode-hex string
Message-Id: <Pine.LNX.4.61.0502280036240.12628@ppepc56.ph.gla.ac.uk>

On Sun, 27 Feb 2005, * Tong * wrote:

> > But you're not going to tell us what it is?
> 
> Well, it actually has nothing to do with unicode. 

Actually, it has a great deal to do with Unicode...

> Here is what I did to decode such string:
> 
> perl -pe 's / \\u([0-9a-f]+) / chr(hex($1)) /giex;' 2>/dev/null;

Fine.  chr(hex($1)) is the Unicode character in question - in Perl's 
native representation.

Thanks.  It just goes to show how seamless Perl's Unicode 
implementation is, when one can use it without even believing in it 
;-)

Perhaps our questioner on another thread, who's determined to prevent 
Perl's unicode from working for him, could take a lesson from this.

all the best


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

Date: 27 Feb 2005 17:25:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: maximum size of a hash table
Message-Id: <cvsvq3$hap$1@mamenchi.zrz.TU-Berlin.DE>

John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> 
> > John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> >> Anno Siegel wrote:
> >> 
> >> > John Bokma  <postmaster@castleamber.com> wrote in
> >> > comp.lang.perl.misc: 

[hashes]

> >> I am happy with constant avg length of c, and hence O(1) look up.
> > 
> > Fine.  My point is that there are useful applications of hash tables
> > also in the O(n) range.
> 
> Uhm, like? (Ok, memory stress testing is one).

It's a simple space/time tradeoff.  You only get constant access time
when collisions are rare, so the number of buckets must be larger than
the number of keys.  Say you expect a million keys and linear search
is too slow by a factor of 100.  Use a hash with 100 buckets (some more
to compensate overhead).  That gives you the necessary speedup with
almost no memory overhead, as opposed to a hash of more than a million
buckets for constant access time.  That's a useful hash application
well in the linear range.

Anno


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

Date: 27 Feb 2005 16:11:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: OOP Tutorial
Message-Id: <cvsrf9$evs$1@mamenchi.zrz.TU-Berlin.DE>

Leslie Viljoen  <leslievNO@SPAMicoc.co.za> wrote in comp.lang.perl.misc:
> 
> > To carry on...

[...]

> mega_animal! SUPER is a bit of a funny choice for an ancestor though, 
> isn't it? Expecially since descendants are most often more "super" than
> their parents.

I agree, the subclass/superclass/isa terminology of OO doesn't match the
view of things of a programmer.  In inheriting from a base class, we usually
don't mean to say that our objects are to be considered special cases of
the base class. We allow them to share some properties.  @ISA would be
better named @MAY_IN_A_CERTAIN_LIGHT_LOOK_A_BIT_LIKE_A.

Anno


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

Date: 27 Feb 2005 20:31:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OOP Tutorial
Message-Id: <slrnd24bg6.7ub.abigail@alexandra.abigail.nl>

Brian McCauley (nobull@mail.com) wrote on MMMMCXCVI September MCMXCIII in
<URL:news:cvnpkt$69f$1@sun3.bham.ac.uk>:
''  
''  Calling a constuctor on an existing object is generally considered a BAD 
''  THING.

Well, I give you that *some* people consider it a bad thing, but I dispute
it's considered generally.

''          Having a constuctor that can be called on an existing object and 
''  does something other than act as a (copy) constructor is an even worse 
''  thing. [...]

Frankly, I fail to see the what the problem is. Noone seems to have a
problem with

    $obj1 = $obj2 -> some_method_that_isnot_called_new;

But if "ref ($obj1) eq ref ($obj2)", the we have suddenly those irrational
fears and confusions happen, just like double quoted strings that don't
interpolate a variable, or a map in void context.

I never had a problem with

    $obj1 = $obj2 -> method;

and I don't plan to make exceptions for methods that happen to return
objects from the same class.



Abigail
-- 
perl -wle 'sub _ "Just another Perl Hacker"; print prototype \&_'


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

Date: Sun, 27 Feb 2005 22:32:25 +0200
From: Leslie Viljoen <lesliev@NOSPAMicoc.co.za>
Subject: Re: OOP Tutorial
Message-Id: <W-2dnUjTBcP-s7_fRVn-gg@is.co.za>

Anno Siegel wrote:
> Leslie Viljoen  <leslievNO@SPAMicoc.co.za> wrote in comp.lang.perl.misc:
> 
>>>To carry on...
> 
> 
> [...]
> 
> 
>>mega_animal! SUPER is a bit of a funny choice for an ancestor though, 
>>isn't it? Expecially since descendants are most often more "super" than
>>their parents.
> 
> 
> I agree, the subclass/superclass/isa terminology of OO doesn't match the
> view of things of a programmer.  In inheriting from a base class, we usually
> don't mean to say that our objects are to be considered special cases of
> the base class. We allow them to share some properties.  @ISA would be
> better named @MAY_IN_A_CERTAIN_LIGHT_LOOK_A_BIT_LIKE_A.
> 
> Anno
Or @COULD_BE_BETTER_COULD_BE_WORSE.
@WAS_A might actually be a good one.


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

Date: 27 Feb 2005 20:56:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: OOP Tutorial
Message-Id: <cvtc53$n7u$1@mamenchi.zrz.TU-Berlin.DE>

Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> Brian McCauley (nobull@mail.com) wrote on MMMMCXCVI September MCMXCIII in
> <URL:news:cvnpkt$69f$1@sun3.bham.ac.uk>:

[making ->new an object method]

> Frankly, I fail to see the what the problem is. Noone seems to have a
> problem with
> 
>     $obj1 = $obj2 -> some_method_that_isnot_called_new;
> 
> But if "ref ($obj1) eq ref ($obj2)", the we have suddenly those irrational
> fears and confusions happen, just like double quoted strings that don't
> interpolate a variable, or a map in void context.
> 
> I never had a problem with
> 
>     $obj1 = $obj2 -> method;
> 
> and I don't plan to make exceptions for methods that happen to return
> objects from the same class.

That's absolutely fine if it makes sense.  What I have a problem with
is a trend to make ->new object-callable just because you can.  I often
see it in classes where there's no discernible reason why ->new should be
called through an object.  There ought to be a visible or documented
advantage in making it so which is often missing.

Anno


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

Date: 27 Feb 2005 22:14:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OOP Tutorial
Message-Id: <slrnd24hhf.7ub.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCXCVIII
September MCMXCIII in <URL:news:cvtc53$n7u$1@mamenchi.zrz.TU-Berlin.DE>:
-:  Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
-: > Brian McCauley (nobull@mail.com) wrote on MMMMCXCVI September MCMXCIII in
-: > <URL:news:cvnpkt$69f$1@sun3.bham.ac.uk>:
-:  
-:  [making ->new an object method]
-:  
-: > Frankly, I fail to see the what the problem is. Noone seems to have a
-: > problem with
-: > 
-: >     $obj1 = $obj2 -> some_method_that_isnot_called_new;
-: > 
-: > But if "ref ($obj1) eq ref ($obj2)", the we have suddenly those irrational
-: > fears and confusions happen, just like double quoted strings that don't
-: > interpolate a variable, or a map in void context.
-: > 
-: > I never had a problem with
-: > 
-: >     $obj1 = $obj2 -> method;
-: > 
-: > and I don't plan to make exceptions for methods that happen to return
-: > objects from the same class.
-:  
-:  That's absolutely fine if it makes sense.  What I have a problem with
-:  is a trend to make ->new object-callable just because you can.  I often
-:  see it in classes where there's no discernible reason why ->new should be
-:  called through an object.  There ought to be a visible or documented
-:  advantage in making it so which is often missing.


I dunno. Seems to fit perfectly in the Perllish world where arrays can
be numbers and strings regexes. So why not have methods can be both class
and object methods? Just the fact that the author of the method gave you
a *choice* of using it as a class or object method doesn't mean you have
to use it. People used to multi-methods wouldn't have a problem with
either - they would just see it as two methods with different signatures.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Mon, 28 Feb 2005 00:24:35 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Pure Perl OpenSSL Library
Message-Id: <3uudndg-Qo9c-b_fRVnygg@pipex.net>

Marc wrote:
>> 
> My system will receive burst of thousand and more request within short
> period (seconds/minutes), so I want to avoid forks as much as possible.

    Requests for what?  I presume you aren't going to be creating/issuing 
thousands of certificates within minutes.

    If you are trying to validate an "incoming" SSL cerrtificate in Apache 
you should use mod_ssl.  But what are you actually trying to do?

-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: 27 Feb 2005 21:14:49 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: sequences of numbers
Message-Id: <slrnd24e29.7ub.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCXCVII
September MCMXCIII in <URL:news:cvpmjb$g04$1@mamenchi.zrz.TU-Berlin.DE>:
::  Big Daddy  <ihatespam@hotmail.com> wrote in comp.lang.perl.misc:
:: > If I have an array that has elements of the following form
:: > 
:: > 
:: > #!usr/bin/perl
:: > 
:: > my @array;
:: > 
:: > $array[0] = "0 1 2 3 4 4 5";
:: > 
:: > $array[1] = "0 2 2 2 3 4 5";
:: > 
:: > $array[2] = "0 2 2 2 2 3 4";
:: > 
:: > $array[3] = "0 2 6 8 9 10 12";
:: > 
:: > How would I get rid of any elements of the array that have 4 or more 
:: > adjacent alike elements?  For example, in the above array, I would want to 
::  
::      my @sel = map { chop; $_} grep !/(\d+ )\1{3}/, map "$_ ", @array;

You might want to change the regex to:

    /\b(\d+ )\1{3}\b/

or it will filter out

    "12 2 2 2"


Abigail
-- 
perl -wle 'print prototype sub "Just another Perl Hacker" {};'


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

Date: 27 Feb 2005 21:55:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sequences of numbers
Message-Id: <cvtfk0$paa$1@mamenchi.zrz.TU-Berlin.DE>

Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCXCVII
> September MCMXCIII in <URL:news:cvpmjb$g04$1@mamenchi.zrz.TU-Berlin.DE>:
> ::  Big Daddy  <ihatespam@hotmail.com> wrote in comp.lang.perl.misc:

[...]

> :: > $array[2] = "0 2 2 2 2 3 4";
> :: > 
> :: > $array[3] = "0 2 6 8 9 10 12";
> :: > 
> :: > How would I get rid of any elements of the array that have 4 or more 
> :: > adjacent alike elements?  For example, in the above array, I would want to 
> ::  
> ::      my @sel = map { chop; $_} grep !/(\d+ )\1{3}/, map "$_ ", @array;
> 
> You might want to change the regex to:
> 
>     /\b(\d+ )\1{3}\b/
> 
> or it will filter out
> 
>     "12 2 2 2"

Ah, yes.  Thanks.

Anno


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

Date: Mon, 28 Feb 2005 09:50:36 +0800
From: GreenLeaf <newspost@kohombanDELETE.net>
Subject: Re: The meaning of @
Message-Id: <38fbpuF5nrkstU1@individual.net>

Leslie Viljoen wrote:

> Sorry I missed it. Thunderbird does not seem to highlight threads I
> have posted in.

May be OT, but View > Messages > Customize.. :o)

sat


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

Date: Sun, 27 Feb 2005 20:05:09 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Wide character notation, was Re: How to NOT use utf8.
Message-Id: <Pine.LNX.4.61.0502271935490.12103@ppepc56.ph.gla.ac.uk>

On Sun, 27 Feb 2005, Brian McCauley wrote:

> > If we code "\x{0100}\x{DF}\n" (that's "A macron, sharp s"), then Perl
> > *knows* that we need Unicode, and will store a unicode string (which, as we
> > know, is stored internally in its utf8 format).
> 
> > So I don't really understand that:
> > 
> >   "produces a fairly useless mixture of native bytes and UTF-8"
> > 
> > which is quoted above.  What's *wrong* (as I see it) with what's quoted
> > above is that there is an attempt to output a "wide" Unicode character (A
> > macron, \x{100}) without the proper arrangements having been made.
> 
> Yes, it would appear that the feature to which the documentation is 
> referring (putting raw bytes into a UTF8 string with \x{}) was 
> decided to be of negledgible utility

Thanks for the response.  But...

I don't interpret it quite like that.

If you write, let's say, 

  print "\x{9}\x{41}\x{a3}\x{df}\n";

and you havent done the binmode with ":utf8", then Perl will indeed
print the four octets which represent tab, A, pound sterling, sharp s
in ASCII encoding (plus the newline, natch...).

If, on the other hand, you go

  print "\x{9}\x{41}\x{a3}\x{df}\x{100}\n";

then Perl will issue a "Wide character in print" warning, and then
output the *whole* string in utf-8 encoding (eight octets plus the 
newline, since the tab and the "A" need one octet each, whereas the 
other three characters need two octets each).

If, on the other hand, you *do* the ":utf8" thing on the output, then 
*both* lines get output in utf8 encoding (respectively six and eight 
octets before the newline), i.e Perl does *not* attempt to print the 
iso-8859-1-coded bytes to a filehandle that's been opened for :utf8.  

Which (as it seems to me) is all as it -should- be.

> and was removed but the documentation has not caught up.

So it seems.

What it boils down to is that this seems to be working better, in some 
respects, than its documentation.  ;-)

thanks


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

Date: Sun, 27 Feb 2005 21:44:44 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Wide character notation, was Re: How to NOT use utf8.
Message-Id: <Pine.LNX.4.61.0502272141240.12522@ppepc56.ph.gla.ac.uk>

On Sun, 27 Feb 2005, Alan J. Flavell wrote:

> I don't interpret it quite like that.
> 
> If you write, let's say, 
> 
>   print "\x{9}\x{41}\x{a3}\x{df}\n";
> 
> and you havent done the binmode with ":utf8", then Perl will indeed
> print the four octets which represent tab, A, pound sterling, sharp s
> in ASCII encoding (plus the newline, natch...).

Was I half asleep?  I meant that to say "in iso-8859-1 encoding", 
obviously (*how* embarrassing!).

But I meant the rest of it :-}


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7837
***************************************


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