[18600] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 768 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 25 21:05:51 2001

Date: Wed, 25 Apr 2001 18:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988247111-v10-i768@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 25 Apr 2001     Volume: 10 Number: 768

Today's topics:
    Re: 5.6.0 vs. 5.6.1 (was: Re: Issue with 5.004 to 5.6 u (Reinier Post)
    Re: [Very OT] Sex and apathy <miltonroad@btinternet.com>
    Re: [Very OT] Sex and apathy <uri@sysarch.com>
    Re: binary operations <ren@tivoli.com>
    Re: binary operations <bart.lateur@skynet.be>
    Re: Browsing Directories by CGI <stumo@bigfoot.com>
    Re: checking case in perl <mroulha1@email.mot.com>
    Re: checking case in perl <miltonroad@btinternet.com>
    Re: checking case in perl <miltonroad@btinternet.com>
    Re: checking case in perl <ren@tivoli.com>
    Re: crypt function disparity problem (5-i's)
    Re: crypt function disparity problem <mischief@velma.motion.net>
    Re: DBM data stores <jbc@west.net>
    Re: Help for scrpit line.. <lckun@chollian.net>
    Re: Help for scrpit line.. <lckun@chollian.net>
    Re: How to use Perl subroutines/submodules from other s (Anno Siegel)
    Re: Idiom: the expression of a copied & substituted str (Randal L. Schwartz)
    Re: Idiom: the expression of a copied & substituted str <ren@tivoli.com>
    Re: Idiom: the expression of a copied & substituted str <ren@tivoli.com>
    Re: Idiom: the expression of a copied & substituted str <ren@tivoli.com>
    Re: Idiom: the expression of a copied & substituted str (Anno Siegel)
        libgdm NOT! (Homer Wilson Smith)
    Re: match a range of number (Anno Siegel)
    Re: match a range of number <ren@tivoli.com>
    Re: oop bless problem (Anno Siegel)
    Re: oop bless problem <jasonh@colubs.com>
    Re: oop bless problem <bart.lateur@skynet.be>
    Re: oop bless problem (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 25 Apr 2001 23:02:07 GMT
From: rp@win.tue.nl (Reinier Post)
Subject: Re: 5.6.0 vs. 5.6.1 (was: Re: Issue with 5.004 to 5.6 upgrade)
Message-Id: <9c7l1f$nqq$1@news.tue.nl>

h.m.brand@hccnet.nl (H. Merijn Brand) wrote:

>Sorrrrry, but 5.6.1 has *much leaks solved* that were still present in 5.6.0
>
>I'd go for 5.6.1

The 109th test in Template-Toolkit-2.01/t/filter.t dumps core with my
Solaris perl 5.6.1 installation.  5.6.0 passes unharmed on the same
Solaris system.  I can't see all that many differences between the two
installations except the set of CPAN modules installed.

>-- 
>H.Merijn Brand           Amsterdam Perl Mongers 
>(http://www.amsterdam.pm.org/)

-- 
Reinier Post
Eindhoven


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

Date: Thu, 26 Apr 2001 00:36:31 +0100
From: Milton Road <miltonroad@btinternet.com>
Subject: Re: [Very OT] Sex and apathy
Message-Id: <HjIF6.130908$g63.15047089@nnrp3.clara.net>

nobull@mail.com wrote:

> So you believe having sex causes apathy to towards anti-social
> behaviour?  Can you cite any relevant research to back this up?
> 

Anti-social behaviour?  That's quite a laugh really.  Read your posts in 
this thread, and you seem to be the only person exercising behaviour that's 
anti-social.

You don't have to read this group.  You don't have to answer people's 
questions.  You're here of you're own volition.  I'd imagine it unlikely 
that someone is holding a gun to your head right now forcing you to read 
comp.lang.perl.misc.

You're also making the cardinal mistake of 'speaking for the group'.  
Espouse your own hate-filled opinions if you must, but don't presume to 
attribute feelings to the subscribers of an entire newsgroup.  How do you 
know how something is "usually interpreted"?

As for the sex point - speaking for myself, it chills me out and prevents 
me from getting wound up at "insulting" questions from newbies.  No amount 
of sex, no matter how good, prevents me from needing to respond to 
community-destroying meow-merchants as yourself.

Milton



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

Date: Wed, 25 Apr 2001 22:54:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: [Very OT] Sex and apathy
Message-Id: <x7oftkh9p2.fsf@home.sysarch.com>

>>>>> "MR" == Milton Road <miltonroad@btinternet.com> writes:

  MR> As for the sex point - speaking for myself, it chills me out and
  MR> prevents me from getting wound up at "insulting" questions from
  MR> newbies.  No amount of sex, no matter how good, prevents me from
  MR> needing to respond to community-destroying meow-merchants as
  MR> yourself.

sounds as if you haven't had enough sex yourself. why don't you go into
the corner and masturbate for an hour or so? i am sure you do it better
than you code perl and the chill will do you good.

<followups set>

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 25 Apr 2001 17:08:04 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: binary operations
Message-Id: <m3n194vdiz.fsf@dhcp9-172.support.tivoli.com>

On Wed, 25 Apr 2001, rayj00@yahoo.com wrote:

> Now I need to do something like: check
> the bottom 5 bits for a value of 10110
> and if so, do something.
> 
> My question is the how do I do an "if"
> statement? Should it be: if (@array[0...4] eq 10110)???
> Or can I refer to the 5 bits as a whole decimal 22?

You probably want something like:

  if ( ($val & 0b11111) == 0b10110 ) {
    # ...
  }

Note that numbers are numbers are numbers... the only point of the
various types of numeric literals are for programmer convenience and
legibility.  So these are all the same:

  if ( ($val & 0b11111) == 22 ) { }
  if ( ($val & 31) == 22 ) { }
  if ( ($val & 0x1f) == 0x16 ) { }

You may also want to explore the vec function, or even the Bit::Vector
module.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 25 Apr 2001 23:19:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: binary operations
Message-Id: <tnmeetciupti7d3rpcoqg1l4k8l0j26lee@4ax.com>

RayJ wrote:

>I have a hex value, say a5.
>I convert to binary using pack/unpack and
>put the results in an array.
>
>Now I need to do something like: check
>the bottom 5 bits for a value of 10110
>and if so, do something.
>
>My question is the how do I do an "if"
>statement? Should it be: if (@array[0...4] eq 10110)???

Nope.

>Or can I refer to the 5 bits as a whole decimal 22?

You can. Or use 0b10110, which at least works on 5.6.0.

	$bits = 0xa5;
	if(($bits & 31) == 0b10110) {
	    print "Yes!";
	}

It won't print anything, because the lower 5 bits form 5, not 22.

-- 
	Bart.


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

Date: Thu, 26 Apr 2001 00:35:15 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Re: Browsing Directories by CGI
Message-Id: <paJF6.5040$lq1.389278@news6-win.server.ntlworld.com>

Clinton Munden <clinton.munden@alcatel.com> wrote in message
news:3AE70176.619CFB83@alcatel.com...
> What OS are you using?
>
>
> Stuart Moore wrote:
>
> > Is there a module that handles browsing directories (and if possible
> > uploading/downloading) through a CGI interface? My ISP insists I dial
through
> > them to upload through FTP, this'd be a useful way of getting through that.

My ISP (what I want it for) is FreeBSD (I presume a form of unix, I'm afraid I'm
Dos/Win only ;-)




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

Date: Wed, 25 Apr 2001 17:13:01 -0500
From: "Roulhac" <mroulha1@email.mot.com>
Subject: Re: checking case in perl
Message-Id: <9c7ifv$dkt5@nntp.cig.mot.com>

Thanks for all your help... just one more thing...

what if the string contains numbers and non alphabetic characters, like
underscore, etc.  How do I handle that?

thanks again!

"Roulhac" <mroulha1@email.mot.com> wrote in message
news:9c7ali$dkb2@nntp.cig.mot.com...
> Hi all:
>
> I want to parse a string to see if the letters are all uppercase or
> lowercase.  Is there a way to do this in perl?  And if so, could someone
> please give me a snippet of code...
>
> Thanks in advance!
>
>




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

Date: Thu, 26 Apr 2001 00:52:14 +0100
From: Milton Road <miltonroad@btinternet.com>
Subject: Re: checking case in perl
Message-Id: <qyIF6.131024$g63.15050463@nnrp3.clara.net>

Roulhac wrote:

> Hi all:
> 
> I want to parse a string to see if the letters are all uppercase or
> lowercase.  Is there a way to do this in perl?  And if so, could someone
> please give me a snippet of code...
> 
> Thanks in advance!
> 
> 

Depends on what else the string contains.  If it contains spaces and other 
punctuation then these regexps will help you out :-

if ( $string !~ m/[a-z] ){
  # no lowercase characters
  # any alphabetic characters inside are uppercase

  # put code here
}

if ( $string !~ m/[A-Z]/ ){
  # no uppercase characters 
  # any alphabetic characters inside are lowercase

  # put code here
}

There are loads of other regexp options, depending on what your string will 
contain.

Milton.



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

Date: Thu, 26 Apr 2001 00:56:50 +0100
From: Milton Road <miltonroad@btinternet.com>
Subject: Re: checking case in perl
Message-Id: <ICIF6.131061$g63.15051898@nnrp3.clara.net>

if ( $string !~ m/[a-z]/ ){
  # no lowercase characters
  # any alphabetic characters inside are uppercase

  # put code here
}

Doh!  missed a closing slash in my example.....

Hope this helps

Milton




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

Date: 25 Apr 2001 16:03:23 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: checking case in perl
Message-Id: <m3vgnsvgis.fsf@dhcp9-172.support.tivoli.com>

On Wed, 25 Apr 2001, mroulha1@email.mot.com wrote:

> I want to parse a string to see if the letters are all uppercase or
> lowercase.  Is there a way to do this in perl?  And if so, could
> someone please give me a snippet of code...

One easy way to do this is to look for an exception:

if ( /[A-Z]/ ) { print "Contains uppercase letter(s)\n" }
if ( /[a-z]/ ) { print "Contains lowercase letter(s)\n" }

You could also use "tr/a-z//", though I've never been quite clear on
which is faster when you only care if *any one* of the characters are
present.  I suspect tr/// is still going to examine the entire string,
wile m// will stop at the first hit.  Of course, when none of the
characters are present, then they both must examine the entire string.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 25 Apr 2001 22:47:56 GMT
From: fiveyes@iiiii.com (5-i's)
Subject: Re: crypt function disparity problem
Message-Id: <3af951aa.268253712@news.atl.bellsouth.net>

On Wed, 25 Apr 2001 23:32:48 +0200, Boris Zentner <boris@m2b.de>
wrote:

>5-i's wrote:
>
>> I'm obtaining two different results on separate systems and I can't
>> find any reference as to why or even if this is to be expected.
>
>i think it is expected as the manpage say 'Encrypts a string exactly like 
>the crypt(3) function in the C library' perhaps you can use 
>Crypt::UnixCrypt and overload the crypt function.
Found it, bless you, Boris!  I was over at CPAN looking at Crypt::DES
and trying to figure out how to bend it to my needs whenever this
posting went up.

>i get crypt ('password', '47') returns "47amUs3AWvq5A" for my
>linux 2.4.2-ac14 with perl 5.6.1
That's exactly what's needed for the direction the migration has to
go.

Again, thanks to all who responded with such insight.


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

Date: Wed, 25 Apr 2001 22:58:49 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: crypt function disparity problem
Message-Id: <teell995sgrp89@corp.supernews.com>

5-i's <fiveyes@iiiii.com> wrote:
> I'm obtaining two different results on separate systems and I can't
> find any reference as to why or even if this is to be expected.

> Perl Version: 5.00503 
> PERL compile version OS: freebsd 
> crypt ('password', '47') returns "$1$47$Ct/n4hLOONORfPK4lqkC6."

This one _looks_ like an MD5 digest to me, instead of a standard
Unix crypt(3) style password. Are you sure you don't have the system
set up for MD5 system passwords? I'm not a FreeBSD person, but the
standard crypt(3) function could be remapped to an MD5 digest routine
so that programs trying to deal with the system shadow file do
so correctly without modification. Check 'man crypt' on the system
to confirm/rebut this hypothesis.

> Perl Version: 5.00402 
> PERL compile version OS: bsdos 
> crypt ('password', '47') returns "47amUs3AWvq5A"

This looks like a standard Unix crypt, and is exactly what I
get on my Linux machines running the same code. This works
from Perl whether the Linux (RedHat) system uses MD5 or not.

Since these systems use PAM for authentication, they probably
count on the MD5 auth stuff to be accessed through PAM by
applications.

If a system counted on applications needing to access MD5
digested passwords through crypt(3) in the C library, it
could be that someone would have replaced the standard
crypt() in the C library with an MD5 version.

Anyway, the traditional crypt(3) is available in a pure-Perl
form as Crypt::UnixCrypt on CPAN, and the MD5 digest crypt
is available as Crypt::PasswordMD5 as well, although the link
to the documentation for Crypt::PasswordMD5 seems to not be
working at this instant. Take your pick.

> The crypted passwords are functional within their respective Apache
> htaccess schemes, but are mutually incompatible with each other
> (meaning I can't directly migrate a huge htpasswd file, which is a BAD
> thing!).
> I'd appreciate any insight given, since both the faq and Dejanews are
> coming empty for me...

The bad news for migration is that crypt(3) and MD5 are both
digests, so they both only go in one direction, and you will have a
difficult time trying to decode either. You may want to look
into making the target system use the same one-way cryptography
scheme as the source system. It should be easier.

Chris

-- 
You must not lose faith in humanity. Humanity is an ocean;
if a few drops of the ocean are dirty, the ocean does not
become dirty.  -- Mohandas K. Gandhi



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

Date: Wed, 25 Apr 2001 16:33:24 -0700
From: John Callender <jbc@west.net>
Subject: Re: DBM data stores
Message-Id: <3AE75EC4.7BBBFBCC@west.net>

Eric Mosley wrote:
> 
> what I'm worried about is multiple instances of the perl cgi program all
> reading/writing to the same DBM file - is lockin inherently built into the
> DBM package or is there a work around?

I believe it depends on the behavior of the individual DBM
library you are using. For example, GDBM_File, which uses the
GDBM library, allows any number of readers, or just one writer,
at a time. In other words, it has a basic form of file-locking
built in. The tie operation will fail and return a false value if
a suitable lock can't be established; when tying to a GDBM file
from a CGI script I've sometimes used an until loop and a counter
to keep trying to tie to the file a specified number of times,
with intervening sleep calls, so the CGI script will try a few
times, rather than just giving up immediately. You could also
just stick the tie inside an until test, I suppose, if you wanted
the script to block until the tie could be established, though I
imagine that could make life difficult for your Web server under
high-traffic conditions.

If you use DB_File, which uses the Berkeley DB library, you get
more file locking options. More detail on that may be available
to you via perldoc DB_File (or man DB_File).

John


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

Date: Thu, 26 Apr 2001 07:19:04 +0900
From: lckun <lckun@chollian.net>
Subject: Re: Help for scrpit line..
Message-Id: <3AE74D58.50305@chollian.net>



nobull@mail.com wrote:

> lckun <lckun@chollian.net> writes upside down and untrimmed.  In other
> words he is being rude.  And because he's being so rude I'm not
> prepared to catch, gut, clean and cook his fish for him.
> 
> 
Was my english so untrimmed to understand? :-(
Therefore if you feel that i was rude, i am sorry. :-(



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

Date: Thu, 26 Apr 2001 07:29:13 +0900
From: lckun <lckun@chollian.net>
Subject: Re: Help for scrpit line..
Message-Id: <3AE74FB9.9040906@chollian.net>

It does not need to do. Because it runs very well now.. :-)

Anyway, Danke!!

tag

Abigail wrote:

> lee changkun (lckun@informatik.uni-rostock.de) wrote on MMDCCXCIV
> September MCMXCIII in <URL:news:3AE6845A.36A08AB2@informatik.uni-rostock.de>:
> ^^  
> ^^  I think -M is Age of file in days when script started. But what means
> ^^  60/60/24??
> 
> 
> Why don't you ask Perl?
> 
>     perl -wle 'print 60/60/24'
> 
> 
> Abigail



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

Date: 25 Apr 2001 22:59:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to use Perl subroutines/submodules from other server
Message-Id: <9c7krn$lfm$3@mamenchi.zrz.TU-Berlin.DE>

According to Benjamin Goldberg  <goldbb2@earthlink.net>:
> Abigail wrote:
> > 
> > Tony Van der Voort (tvdv@advalvas.be) wrote on MMDCCLXXXIX September
> > MCMXCIII in <URL:news:3ae00aaf.5340546@news.skynet.be>:
> > <> Hello,
> > <>
> > <> I'm trying to make a perl script (CGI) with subroutines in a
> > <> separate file, using the instruction 'require'. This works very
> > <> good. BUT... I want to install this separate file on another
> > <> server. The reason I will do this, is to protect the code of the
> > <> subroutines. The 'require' instruction does not work here. Can
> > <> some-one explain me, how I can solve this problem ?
> > 
> > You forgot the NFS mount the disk from the other server! You should
> > ask the sysadmin of the other server to share the disk with the world,
> > and have the sysadmin of your server mount the remove disk.
> > 
> > Then it will work all handy-dandy.
> 
> If you don't mind the 'protected' code being world readable by anyone
> else who mounts the remote (I assume you meant remote, not remove) disk.

Benjamin, meet Abigail.  Abigail, meet Benjamin.

Anno


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

Date: 25 Apr 2001 15:33:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <m1g0ewd2z0.fsf@halfdome.holdit.com>

>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

Anno> According to Ren Maddox  <ren@tivoli.com>:
>> On 25 Apr 2001, ren@tivoli.com wrote:
>> 
>> > "as_list"?  Probably too confusing...
>> 
>> (And I realize that there isn't really any such thing as a list in a
>> scalar context, but I'm not really sure how else to associate the
>> commonality of behavior of the comma operator and slices.  Perhaps
>> just like that.  Maybe "as_commas"... :))

Anno> I submit "list_or_last".

Since it acts like a comma, how about:

   "comma_nator"

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 25 Apr 2001 15:39:46 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <m34rvcww6l.fsf@dhcp9-172.support.tivoli.com>

On 25 Apr 2001, ren@tivoli.com wrote:

> On Wed, 25 Apr 2001, mischief@velma.motion.net wrote:
> 
>> This is the functionality for which it seems to me John is asking.
> 
> Actually, it isn't.  He's been pretty clear that what he wants is a
> simple expression that returns the modified string.  The same thing

In retrospect, I realized that your function *does* do this.  I got
bogged down in the fact that it modified the original string, which
seemed counter to the original goal.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 25 Apr 2001 16:31:09 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <m3r8ygvf8i.fsf@dhcp9-172.support.tivoli.com>

On 25 Apr 2001, anno4000@lublin.zrz.tu-berlin.de wrote:

> Actually, if anything in Perl approaches a list in scalar context,
> it is a slice.  What absolutely doesn't exist in scalar context is
> a list given in the "( a, b, c)" syntax.

Agreed.  Except...

What do you call that construct as a l-value?

  ($a, $b, $c) = (1, 2, 3);

  ^^^^^^^^^^^^

Seems like that is the exception that makes the rule....

-- 
Ren Maddox
ren@tivoli.com


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

Date: 25 Apr 2001 18:13:13 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <m3ae54vaie.fsf@dhcp9-172.support.tivoli.com>

On 25 Apr 2001, merlyn@stonehenge.com wrote:

> Since it acts like a comma, how about:
> 
>    "comma_nator"
> 
> :-)

Or, "commalnate" (cf. culminate, in case that wasn't clear).

-- 
Ren Maddox
ren@tivoli.com


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

Date: 26 Apr 2001 00:06:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <9c7opn$p8p$2@mamenchi.zrz.TU-Berlin.DE>

According to Ren Maddox  <ren@tivoli.com>:
> On 25 Apr 2001, anno4000@lublin.zrz.tu-berlin.de wrote:
> 
> > Actually, if anything in Perl approaches a list in scalar context,
> > it is a slice.  What absolutely doesn't exist in scalar context is
> > a list given in the "( a, b, c)" syntax.
> 
> Agreed.  Except...
> 
> What do you call that construct as a l-value?
> 
>   ($a, $b, $c) = (1, 2, 3);
> 
>   ^^^^^^^^^^^^

Hm... Maybe I'm dense, but I don't have any problem calling it a list.

If the question is, where is the list context coming from, I'd say
that parentheses on the left side of an assignment are one of the
sources of list context and provide their own.

Anno


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

Date: 25 Apr 2001 20:22:51 -0500
From: homer@adore.lightlink.com (Homer Wilson Smith)
Subject: libgdm NOT!
Message-Id: <3ae76a5b.0@news2.lightlink.com>

     Running Linxu 2.0.38 and perl 5.00x

     How do I compile perl to NOT include libgdbm.so but only
libdb.so?

     Alternately how do I tell perl to use libdb.so with the dbopen()
statement, it seems to insist on using libgdbm which is incompatible
with the file I wish to read.

     Thanks in advance.

     Homer

--
------------------------------------------------------------------------
Homer Wilson Smith   Clean Air, Clear Water,  Art Matrix - Lightlink
(607) 277-0959       A Green Earth and Peace. Internet Access, Ithaca NY
homer@lightlink.com  Is that too much to ask? http://www.lightlink.com


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

Date: 25 Apr 2001 22:04:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: match a range of number
Message-Id: <9c7hkp$j5t$6@mamenchi.zrz.TU-Berlin.DE>

According to Abigail <abigail@foad.org>:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCXCIV
> September MCMXCIII in <URL:news:9c78g5$dfi$1@mamenchi.zrz.TU-Berlin.DE>:
> ()  
> ()  Well, it doesn't have the intuitive appeal of the threads of
> ()  inequalities mathematicians love, but if you go that way, you
> ()  could go a step further and do:
> ()  
> ()      sub strictly_sorted {
> ()          @_ > 1 ?  $_[ 0] < $_[ 1] && do { shift; &strictly_sorted } : 1;
> ()      }
> 
> But that has an ugly case (or if).
> 
>     sub strictly_sorted {
>         @_ <= 1 || $_ [0] < $_ [1] && do {shift; &strictly_sorted}
>     }

Ah, yes.  I tried something similar and couldn't quite make it.  I
wanted to add a remark about logical programming style in Perl.
 
> Or even:
> 
>     sub strictly_sorted {
>         strictly_sorted (scalar (@_), 2) ||
>         $_ [0] < $_ [1] && strictly_sorted @_ [1 .. $#_];
>     }

Oh dear.  And the do-block is gone too.  I love you.

Anno


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

Date: 25 Apr 2001 15:59:35 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: match a range of number
Message-Id: <m3zod4vgp4.fsf@dhcp9-172.support.tivoli.com>

On Wed, 25 Apr 2001, eins@durchnull.de wrote:

> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> According to Rudolf Polzer <eins@durchnull.de>:
>> > Rudolf Polzer <eins@durchnull.de> wrote:
>> > > 
>> > > Pascal supports
>> > > 
>> > > if i in [3..8] then begin ... end;
>> > > 
>> > > while 3..8 is a set. But not really because i has to be a small
>> > > ordinal type (no float).
>> > 
>> > I wanted to say: There are languages that support this.
>> 
>> Support what?  The "123 < $i < 456" syntax?  No.  Checking if
>> an integer is in a range in one operation?  Perl does that too:
>> 
>>     grep $_ == $i, 3 .. 8;
>> 
>> What is your point?
> 
> Nothing now. I did not think of grep, and both methods have the same
> problem: they work only with integers and make trouble when using
> big ranges.

Furthermore, neither can be readily extended to handle things like:

  0 < $i < $j < 100

There has been a solution posted that does handle this, but it was
pretty specific.  I doubt there is much need for it, but it might be
nice to have a facility similar to sort, but that checks the order
rather than changing it.

if(sorted { $a < $b } 0, $i, $j, 100) {
  # ...
}

Hmm...

sub sorted (&@) {
  return 1 if @_ == 2;          # one item is always sorted
  local *a = \$_[1];
  local *b = \$_[2];
  delete $_[1];
  return $_[0]->() && &sorted;  # keep current arg list (avoid copy)
}

print "Sorted\n" if sorted { $a <= $b } -4, -2, 0, 0, 1, 5, 7;

-- 
Ren Maddox
ren@tivoli.com


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

Date: 25 Apr 2001 22:36:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: oop bless problem
Message-Id: <9c7jgu$lfm$2@mamenchi.zrz.TU-Berlin.DE>

According to Jason Hurst <jasonh@colubs.com>:
> I'm relatively new to oop and I'm having some problems with inheritance.
> I'm trying to make a little module to make it easy to save state to a
> database over cgi.. I'm extending from cgi.pm.
> 
> When i create a new object, i define it as a new cgi
> my $self = new CGI;

The CGI->new() syntax is preferred.

> but when i bless it, i can't access any of the cgi methods???

Why do you think you must bless it?  It is blessed when it comes
from new().

> i have cgi defined in my @ISA and its included.  I just don't get it.  Here

[...]

You seem confused about the roles of the author and the user of
an object-oriented module.  All the blessing, and setting up of
@ISA, is the author's job.  As a user you just call new() to get
an object and then call methods on it.

Well, that's simplified, but it certainly goes for most uses of
CGI.pm.

Anno


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

Date: Wed, 25 Apr 2001 16:06:03 -0700
From: "Jason Hurst" <jasonh@colubs.com>
Subject: Re: oop bless problem
Message-Id: <3ae7585b$0$145@wodc7nh7.news.uu.net>

no, sorry, I'm trying to extend cgi.pm.  i.e, I'm using it as my super
class.


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9c7jgu$lfm$2@mamenchi.zrz.TU-Berlin.DE...
> According to Jason Hurst <jasonh@colubs.com>:
> > I'm relatively new to oop and I'm having some problems with inheritance.
> > I'm trying to make a little module to make it easy to save state to a
> > database over cgi.. I'm extending from cgi.pm.
> >
> > When i create a new object, i define it as a new cgi
> > my $self = new CGI;
>
> The CGI->new() syntax is preferred.
>
> > but when i bless it, i can't access any of the cgi methods???
>
> Why do you think you must bless it?  It is blessed when it comes
> from new().
>
> > i have cgi defined in my @ISA and its included.  I just don't get it.
Here
>
> [...]
>
> You seem confused about the roles of the author and the user of
> an object-oriented module.  All the blessing, and setting up of
> @ISA, is the author's job.  As a user you just call new() to get
> an object and then call methods on it.
>
> Well, that's simplified, but it certainly goes for most uses of
> CGI.pm.
>
> Anno




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

Date: Wed, 25 Apr 2001 23:27:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: oop bless problem
Message-Id: <vcneet4t7qb3ivrql7auchg58akb13u4e3@4ax.com>

Jason Hurst wrote:

>my $self = new CGI;
>but when i bless it, i can't access any of the cgi methods???
>i have cgi defined in my @ISA and its included.  I just don't get it.

Case? It's "CGI", not "cgi".

-- 
	Bart.


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

Date: 25 Apr 2001 23:50:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: oop bless problem
Message-Id: <9c7nrt$p8p$1@mamenchi.zrz.TU-Berlin.DE>

According to Jason Hurst <jasonh@colubs.com>:
> no, sorry, I'm trying to extend cgi.pm.  i.e, I'm using it as my super
> class.

Please don't top-post.  The words you are referring to are a mile down,
or would be if I had left them in.

[jeopardectomy]

Inheritance as an extension method is overrated. (At least in
Perl OO, of which some may say it doesn't exist. Ahem.) But if
all you want to do is add a few methods it may be fine.

If you hadn't made a mess of the thread, I would have preferred to
point out your errors one by one (there aren't that many).  This
way, I'll just throw a demo script at you that demonstrates how
to inherit from CGI.  It still doesn't bless anything explicitly.

Anno

#!/usr/bin/perl
use warnings; use strict; $| = 1;

use CGI;

# build class CGI_Ext:
@CGI_Ext::ISA = qw( CGI);

sub CGI_Ext::othermethod {
    print "here\n";
}

# use it (still) in package main:
my $obj = CGI_Ext->new;
print $obj->header; # call a CGI method
$obj->othermethod;  # call a CGI_Ext method


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

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.  

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


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