[10299] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3891 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 5 13:57:36 1998

Date: Mon, 5 Oct 98 06:00:21 -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           Mon, 5 Oct 1998     Volume: 8 Number: 3891

Today's topics:
    Re: Common prefix for an array of strings (Bart Lateur)
        DBD Oracle binary for win32 <avivc@ibm.net>
    Re: DEL in PERL <jimbo@soundimages.co.uk>
    Re: free book on sh/sed/awk <nsriram@india.hp.com>
        How to open a command that pipes both in and out ??? <zal@rest.ru>
    Re: How to open a command that pipes both in and out ?? <erhmiru@erh.ericsson.se>
    Re: I hate it when I do that. sir_roland@my-dejanews.com
    Re: I hate it when I do that. sir_roland@my-dejanews.com
    Re: ip addresses <jimbo@soundimages.co.uk>
    Re: ip addresses (Gary Cutrer)
    Re: mod_perl woes (I.J. Garlick)
    Re: Need IP Address Sort Subroutine <jdporter@min.net>
    Re: passing javascript vars to CGI <garethr@cre.canon.co.uk>
    Re: Perl as solution? <jimbo@soundimages.co.uk>
        perl2c script/module available? <ra5815@email.sps.mot.com>
        Please Help <koh_cc@pacific.net.sg>
    Re: POLL: Perl features springing into your face <jimbo@soundimages.co.uk>
        polymorphism-1.00 <max@st520.dotcom.fr>
        Reused lexically scoped variable not dereferenced in ti (Roberto)
    Re: Reused lexically scoped variable not dereferenced i <garethr@cre.canon.co.uk>
    Re: RFC: "Build'n'Play" installation tool <jimbo@soundimages.co.uk>
    Re: send geroge reese (was Re: Call for Participation:  <jdporter@min.net>
    Re: Survey Script <matt@whiterabbit.co.uk>
    Re: using sendmail with accents in a cgi? <garethr@cre.canon.co.uk>
    Re: What is the maining of "Bare word" (Andreas Grueninger)
        Win32::Perl update/suggestion francisb@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 05 Oct 1998 12:51:18 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Common prefix for an array of strings
Message-Id: <3619c066.3320106@news.ping.be>

Bart Lateur wrote:

>    $commonlength = &min(@string);

Argh! That should of course be

    $commonlength = &min( map { length } @string);

I hate it when I do that. ;-)
	Bart.


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

Date: Mon, 05 Oct 1998 22:32:24 +1000
From: Aviv Cohen <avivc@ibm.net>
To: danzuck@my-dejanews.com, brhess@email.msn.com
Subject: DBD Oracle binary for win32
Message-Id: <3618BC58.E1A810BA@ibm.net>

I am looking for a binary of DBD Oracle for win32 (x86) perl. I do not
have a C compiler.
Thanks in advance.



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

Date: 05 Oct 1998 12:34:19 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: DEL in PERL
Message-Id: <uvhlzs0n8.fsf@jimbosntserver.soundimages.co.uk>

"Computer Guru" <computerguru@mailexcite.com> writes:

> 
> When I copied the script you gave me..it looked kind of funny..I haven't
> been doing Perl long, but I just had this feeling, so I decided to run the
> script on my developmental machine. I changed the path to c:\perl\bin
> (which is my win95 path) and ran the script....it deleted the whole hard
> drive! A 2 G drive in 15 seconds! Good thing a lost 2 days work instead of
> months! Having a rogue script like that on a server can definitely decimate
> the sanity of the net admin! I don't think anyone should run that script
> unless they don't value their own data or couldnt care less about someone
> else's! As an aside....I doubt Virus scanners have the capability to scan
> Perl Scripts.
> 
> Computer Guru

Slow down - Guru. Bit of a misnomer, don't you think?

If the script looked funny, disect it - Then run it. Typos take us all
unawares. If you fail to remember the Unix heritage of Perl you will
find your arse in the jaws of ignorance; something akin to your ass in
a sling. If you don't know Unix - get a nutshell.

The script itself isn't rogue. Only the user. Contributions by all but
a select few can lead to traumas, occasionally. Remember that. If you
felt it was a bit off, why didn't you reply, wait for the answer, then
proceed? It turns out that someone did point out the missing command
line switch:

Mark-Jason Dominus writes:
> That command will erase everything. I think you meant to write
>
>	find2perl / -name '*.bak' -exec rm -f {} \;

As an aside - Win95 is a virus.
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: Mon, 05 Oct 1998 16:24:13 +0530
From: Sriram N <nsriram@india.hp.com>
Subject: Re: free book on sh/sed/awk
Message-Id: <3618A555.32328B03@india.hp.com>

Go check out this site:

    http://www.lawandco.com/research/research.html

and follow the links or do asearch there - you are sure to find a good
*free* source for anything concerning Unix.

Regards,
Sriram N
L. M. Schmitt wrote:


> FAQ:
> Is there a free tutorial/book on SED and AWK on the market?
> In particular, for computer novices.
> =================================================
> There exists a manuscript:
> "Combining the Bourne-shell, sed and awk
> in the UNIX environment for language analysis"
> by Lothar M. Schmitt (The University of Aizu)
> and  Kiel T. Christianson (Michigan State University).
>
> It contains a tutorial on the Bourne shell, sed and awk
> which is general enough in its scope for most users.
>
> =================================================
> Availability of the manuscript:
>
> ERIC Document service:
> http://www.aspensys.com/eric/
>
> Posting:
> ftp://ftp.u-aizu.ac.jp/u-aizu/doc/Tech-Report/1997/97-2-007.tar.gz
>
> E-mail:
> lothar@u-aizu.ac.jp
>
> =================================================
> Availabiliy of sh/sed/awk for DOS/Windows:
> http://www.cs.utah.edu/csinfo/texinfo/texinfo.html
>
> Availabillity of free UNIX for PC: (how to get started)
> http://sunsite.unc.edu/mdw/LDP/gs/gs.html
>
> =================================================
> Content:
> Tutorial on the Bourne-shell, sed and awk under UNIX.
> Constructing tools for language analysis in research
> and teaching using sh, sed, and awk:
> searches for words, phrases, grammatical patterns and phonemic
> patterns in text;
> statistical evaluation of texts in regard to such searches;
> transformation of phonetic, phonemic or typographic
> transcriptions;
> comparison of texts in various respects;
> lexical-etymological analysis;
> concordance;
> assistance in translating text;
> assistance in learning languages;
> assistance in teaching languages;
> and text processing and formatting.
>
>
>

--
_____________________________________________________________________________
Sriram N                              Phone : 91 080 225 1554 Extn 1273
HP ISO Ltd.                           Email : nsriram@india.hp.com
30 Cunningham Road                    Telnet: 847 1273
Bangalore-52
560 052
_____________________________________________________________________________





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

Date: Mon, 5 Oct 1998 17:13:35 +0600
From: "Aleksey Zvyagin" <zal@rest.ru>
Subject: How to open a command that pipes both in and out ???
Message-Id: <6va9l1$t63$1@news.mplik.ru>

Hi, All!

I want to do following:
to open the command by 'open' function that this command will be piped by
opened file descriptor and pipes this file descriptor. I thought to do this
as:

open DESCR, "|program|";
while (<DESCR>) # reading from DESCR
{
 ...
 print DESCR "some thing\n"; # writing to DESCR
}
close DESCR;

But this example doesn't work :( But the perl with -wc options says me "OK"
and this example working withput any errors but doesn't do that i want :(
How may i do this?

Please,  to send your copy answer to my E-mail: zal@rest.ru

Future thanks ;-)




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

Date: 05 Oct 1998 13:47:28 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: zal@rest.ru
Subject: Re: How to open a command that pipes both in and out ???
Message-Id: <la67dz5iy7.fsf@erh.ericsson.se>

"Aleksey Zvyagin" <zal@rest.ru> writes:
> Hi, All!
> 
> I want to do following:
> to open the command by 'open' function that this command will be piped by
> opened file descriptor and pipes this file descriptor. I thought to do this
> as:

You cannot do this with simple open. What you need is open2 or open3. See
derldoc open2 for further reference.

Michal


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

Date: Mon, 05 Oct 1998 11:05:11 GMT
From: sir_roland@my-dejanews.com
Subject: Re: I hate it when I do that.
Message-Id: <6va957$6st$1@nnrp1.dejanews.com>

In article <361624f6.2420709@news.ping.be>,
  bart.mediamind@ping.be (Bart Lateur) wrote:
> Andrew M. Langmead wrote:
 ...
> BTW a "nice" way to manipulate a variable through $_, is using "for":
>
> 	for($ary[-1]) {
> 		chomp;
> 		tr/,/./;
> 	}
>
> This will manipulate the last item of this array.

Nifty...

> It's actually a looping construct, but with only one item in the array
> it's looping through, it will be executed exactly once. I would like it
> if Perl allowed a yet more conventient synonym for the "for" (but
> what?), but it will do for now.

How about "with" and "witheach"? And of course a gratuituous "do":

	with ($ary[-1]) do {
		chomp;
		tr/,/./;
	}

	witheach (@elements) {
		s/this/that/;
	}

Yeah, I really like the taste of that, as it definitely
increases code comprehensibility.

Roland
--
Sir_Roland@my-dejanews.com    | "Microsoft is NOT the ANSWER."
   A humble Knight on his     |  "Microsoft is the QUESTION,"
    quest for Avatarhood      |     "and the ANSWER is NO!"

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 05 Oct 1998 11:26:58 GMT
From: sir_roland@my-dejanews.com
Subject: Re: I hate it when I do that.
Message-Id: <6vaae2$8l8$1@nnrp1.dejanews.com>

In article <361624f6.2420709@news.ping.be>,
  bart.mediamind@ping.be (Bart Lateur) wrote:
 ...
> BTW a "nice" way to manipulate a variable through $_, is using "for":
>
> 	for($ary[-1]) {
> 		chomp;
> 		tr/,/./;
> 	}
>
> This will manipulate the last item of this array.

Nifty...

> It's actually a looping construct, but with only one item in the array
> it's looping through, it will be executed exactly once. I would like it
> if Perl allowed a yet more convenient synonym for the "for" (but
> what?), but it will do for now.

How about "with" and "witheach"? And of course a gratuitous "do":

	with ($ary[-1]) do {
		chomp;
		s/tis/tat/;
	}

	witheach (@elements) {
		tr/ans /late/;
	}

Yeah, this sounds right. And will improve code comprehensibility too.
Perl Gods, any takers?

Roland
--
Sir_Roland@my-dejanews.com    | "Microsoft is NOT the ANSWER."
   A humble Knight on his     |  "Microsoft is the QUESTION,"
    quest for Avatarhood      |     "and the ANSWER is NO!"

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 05 Oct 1998 12:58:09 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: ip addresses
Message-Id: <usoh3rzji.fsf@jimbosntserver.soundimages.co.uk>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:

> 
> Daryn Brightblade wrote:
> 
> > Just a quick desperation question please.
> > is it at all possible for me to use a single command in perl
> > to bring up the network config of the pc in question please?
> 
> Have you tried 'netstat /?' You should be able to see all interfaces,
> ports, protocols and ips with that command. Perl doesn't have an
> internal function to do this that I know of.
> 

Yeah. But he still has to parse the command output for the results
he's looking for. What he wants is a file statistics type of
return. Not just the text returned from the command. What he wants is
a nanny.

Anyway, why is routing the output to a text file the long way around?
Further, what not just capture the output in a variable and parse
that?

So I think he should pick a couple of net commands and write a couple
of useful subs that will take the command output and turn it into
useful results that can be returned just like file statistics. That
way he won't need a nanny. It'll be fun to be grown up. I'm sure he'll
like it.

All those in favour indicate by shouting 'HEAR HEAR'.
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: Mon, 05 Oct 1998 07:40:28 -0500
From: gary@webstar.net (Gary Cutrer)
Subject: Re: ip addresses
Message-Id: <3AD213DB65E48823.C7A1AA19C198B11D.B277580FDF9E9433@library-proxy.airnews.net>

In article <usoh3rzji.fsf@jimbosntserver.soundimages.co.uk>, Jim Brewer
<jimbo@soundimages.co.uk> wrote:

> Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:
> 
> > 
> > Daryn Brightblade wrote:
> > 
> > > Just a quick desperation question please.
> > > is it at all possible for me to use a single command in perl
> > > to bring up the network config of the pc in question please?
> > 
> > Have you tried 'netstat /?' You should be able to see all interfaces,
> > ports, protocols and ips with that command. Perl doesn't have an
> > internal function to do this that I know of.
> > 
> 
> Yeah. But he still has to parse the command output for the results
> he's looking for. What he wants is a file statistics type of
> return. Not just the text returned from the command. What he wants is
> a nanny.
> 
> Anyway, why is routing the output to a text file the long way around?
> Further, what not just capture the output in a variable and parse
> that?
> 
> So I think he should pick a couple of net commands and write a couple
> of useful subs that will take the command output and turn it into
> useful results that can be returned just like file statistics. That
> way he won't need a nanny. It'll be fun to be grown up. I'm sure he'll
> like it.
> 
> All those in favour indicate by shouting 'HEAR HEAR'.


Gosh, do you think we could be a *little* more snooty?

-- 
Gary Cutrer
Spur Network Systems
Sphynx Web Solutions

gary@sphynx.com


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

Date: Mon, 5 Oct 1998 09:18:29 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: mod_perl woes
Message-Id: <F0CKIt.Koz@csc.liv.ac.uk>

In article <slrn7106dr.2g7.jsd@hudsucker.gamespot.com>,
jsd@hudsucker.gamespot.com (Jon Drukman) writes:
> In article <6uonq7$5hm@bolt.sonic.net>, Peter Rowell wrote:
>>I assume you know where and what your globals are and can simply
>>create a routine call initialize_globals to be called each time
>>you start a new transaction.  I find it easier to do this at the
>>start of a transaction (rather than at the end) because of the
>>way my brain is wired.  When creating this routine, it may dawn
>>on you that "Damn!  I have a *lot* of globals!", which is a good
>>learning experience in and of itself.
> 
> btw, while over-reliance on globals is usually a sign of sloppy
> design... if you do find yourself with a ton, you might consider
> putting them in a hash, so you can undef it with one statement instead 
> of many.  (what is a namespace anyway but a hash?)
> 

I know, I got one helluva shock when I ran my old version under mod_perl,
way too many globals, so I rewrote it as an oop class (it was supposed to
be like that in the first place).

>>This routine also would be a good place to reset any of perl's globals
>>that you might have messed with.  For instance, $/ may have been set to
>>a different input record separator half-way through the script, but you
>>expected it to be the default value for the first half.  So remember to
>>set these to their expected initial state.
> 
> and consider using the much-maligned local() command for its One True
> Purpose: quick and dirty changing of Perl globals... ie:
> 
> {
>   local $/="some wacky record separator";
>   ... stuff with $/ ...
> }
> ... at this point $/ is back to whatever it was before the block
> started ...

Yep that one cught me out as well, it's so much easier to slurp whole files
sometimes, especially when I know they are only of a limited size.

> 
> with mod_perl i find use strict to be absolutely invaluable.  if your
> program runs clean under strict, you are WAY ahead of the game.
> 

Already do this (doesn't everybody? makes me shudder just to think of not
running without 'use strict'), that's what caused me to rewrite it, I got
hundreds of error_log messages telling me that Global A would no longer
have the same value at the end of subroutine XYZ as it did upon entering
said sub. Yes I knew that it was designed that way but no it insisted on
telling me every single time, so they all had to go. I tend to get a bit 
pedantic about all error messages, even warnings, I don't like my scripts
to have any, none, nada, zip, zero, etc....

The problem is, and why I asked my original question, the httpd processes
seem to grow at a steady rate, after a week one had reached 16Mb. I am
pretty sure I close all files and other obvious stuff like that, but I am
using a few tie hashes and I am not convinced they are being destroyed.
Also I use open2/3 once or twice and this seems to be leaving zombie
processes behind even though I close them (read, write and error handles
were approprite), I have not had access for over a week (holidays and why
I am a little late replying, sorry) and the number of these zombies grew
very large.

So naybody got any ideas? Also is there any good books/faqs on this mod_perl
stuff? other than the faq that comes with it, I have read it but it seems
to be a bit vague on this issue.

-- 
--
Ian J. Garlick
<ijg@csc.liv.ac.uk>

Your motives for doing whatever good deed you may have in mind will be
misinterpreted by somebody.



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

Date: Mon, 05 Oct 1998 08:55:28 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <3618C1C0.70675F71@min.net>

Michal Rutka wrote:
> 
> Improvement 1:
> 
>  @sorted_lines = sort {get_ipa($a) cmp get_ipa($b)} @list;
>  # Where get_ipa() can be:
>  sub get_ipa{
>      return udef unless $_[0] =~ /.*: ([\d.]+)#/;
>      return pack("C4",split(/\./,$1));
>  }
>
>  # Or more correct:
>  use Socket;
>  sub get_ipa{
>      return udef unless $_[0] =~ /.*: ([\d.]+)#/;
>      return inet_aton($1);
>  }

Thank you for noting the difference.

Hey, what's 'udef'?  I suppose you didn't actually run this code?


> Improvement 2:
>  @sorted_lines = map {substr($_,4)} sort map {get_ipa($_).$_} @list;
> 
> This solution is quite similar to ST but faster. It does not use
> dereference during sort and finall map should be faster too.

Indeed, very similar to ST.

> as map creates a new array it will always suffer from speed
> penalty, as on most systems memory allocation is the most time consuming
> operation. 

This does indeed seem to be the case.

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


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

Date: Mon, 5 Oct 1998 11:36:29 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: passing javascript vars to CGI
Message-Id: <sir9wn5jgi.fsf@cre.canon.co.uk>

"Phinneas G. Stone" <phinneas@eskimo.com> wrote:
> What I am trying to do is enter a list of items into a textarea to be
> subsequently passed to perl through cgi, joined into a :: delimited
> string and stored in a single field of a database. Later on, the
> script will split the string to create an array that will be used to
> display the list as a bulleted list. Still with me? Now, each time the
> form is used there may be a different amount of items (bullets), so I
> can't just initially create the form with a hard-coded group of text
> inputs. [...] So if I can enter the list of bullets into a textarea,
> separated by line breaks, I could translate the line breaks into ::
> and avoid the prompt box and individual text inputs altogether.

Your description is hard for me to understand.  I am guessing that you
are trying to do the following:

  You want to present a single form that allows the user to enter
  arbitrarily many items.  Your proposed mechanism is to present the
  user with a <TEXTAREA> input field, into which the user will enter the
  items, one per line.

This solution works fine when I test it with Perl 5.004 and Netscape
4.05.  For example:

  test.html
  ----------------------------------------------------------------------
  <html>
  <head><title>Textarea test</title></head>
  <body>
    <form method="post" action="/cgi-bin/test.pl">
      <textarea name="foo" cols="80" rows="10"></textarea><br>
      <input type="submit">
    </form>
  </body>
  </html>

  test.pl
  ----------------------------------------------------------------------
  #!/usr/local/bin/perl -w

  use strict;
  use CGI::Request;

  my $request = CGI::Request->new;
  my @lines = split /\r\n/, $request->param('foo');  # note CRLF

  print "Content-Type: text/html\n\n";
  print "<html><body><ul><li>", (join '<li>', @lines),
        "</ul></body></html>";

Note that line breaks in the <TEXTAREA> contents are transmitted as
carriage return - line feed pairs.  (See section 17.13.4 of the HTML 4.0
specification, http://www.w3.org/TR/REC-html40/.)

An alternative solution would be to present the user with a single line
input field and a "input this item" button.  When pressed, the button
invokes a JavaScript function that appends the item to a hidden field
using code like 

  <INPUT TYPE=BUTTON ONCLICK="this.hidden.value += "::" + this.single.value">

I note in passing that your claim

> I can't put it into a hidden field because all the form html code has
> already been written to the browser window!

is wrong; JavaScript can write to form values.

-- 
Gareth Rees


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

Date: 05 Oct 1998 12:09:40 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Perl as solution?
Message-Id: <uww6fs1sb.fsf@jimbosntserver.soundimages.co.uk>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:

> 
> Actually, it would seem not. Inconsiderate perhaps, but not always
> annoying. They are seemingly willing to work with me and my neighbors.
> I'm glad really. The cop last night was completely into the pilot..:)
> *giggle* So was the neighbor even if his wife was ready to shoot
> me...toy factor is everything :) I love engineers. 

Elaine, please stop!!! You'll destroy us all!!! Only a TRULY perverted
person would insist on being this bloody happy. Sicko!!!
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: Mon, 05 Oct 1998 06:36:40 -0500
From: Richard Christensen <ra5815@email.sps.mot.com>
Subject: perl2c script/module available?
Message-Id: <3618AF55.886DC36C@email.sps.mot.com>

For very specific reasons I need to code several of my perl scripts to C and
make small executables from them.  I don't normally do this, this is a special
occasion.  So, is there a way to do this?  Is the byte-compiled code what I
want?  I am have a difficult time searching the web/news/archives for this
topic, except for the no hits resulting from perl2c.

Thanks.
Richard Christensen



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

Date: Mon, 05 Oct 1998 19:46:47 -0700
From: Steven <koh_cc@pacific.net.sg>
Subject: Please Help
Message-Id: <36198496.5E0BC854@pacific.net.sg>

hi,

    l've a problem to install perl interpreter 5.0 onto lotus domino web
server.

   After installation, the .pl still cannot be execute at my browser.

   How do l register the .pl into the register to NT server, such that
the web server

   would "recognise" .pl.





--


with regards
steven

Tel : 7711303

Have a nice day !!!

Bye




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

Date: 05 Oct 1998 12:03:58 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: POLL: Perl features springing into your face
Message-Id: <uyaqvs21t.fsf@jimbosntserver.soundimages.co.uk>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:

> 
> Man, I gotta stop working weekends....
> 

Elaine, you don't work weekends. You don't work at all. Be honest -
You 'Happy Fun Ball'!!!

God help the pnuematic crowd!!! Or the asmatic crowd? Or the...

Well, God help us each and every one. The 'Happy Fun Ball' is in
town. Daily from 8 to 5. Weekends too!!!
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: 5 Oct 1998 14:44:23 +0200
From: Maxime Soule <max@st520.dotcom.fr>
Subject: polymorphism-1.00
Message-Id: <wyyaqvp49k.fsf@st520.dotcom.fr>


Polymorphism is now possible in Perl !

	http://www.dotcom.fr/max/polymorphism-1.00.tar.gz

This is the polymorphism module for Perl5. It makes polymorphism
possible in Perl easily and automatically.

Perl is an OO Language, but can't do directly polymorphism. The
programmer must manage it itself. It is not a very clean way, the
source may become hard to read.

The polymorphism module do it for you. It defines a method that
will switch on the adequate sub you have defined according to its
prototype.

The prototype is based on Perl sub prototype with additions to make
class object prototyping possible.

To install this module, cd to the directory that this README file is
in and type the following:

        perl Makefile.PL
        make
        make test
        make install

Documentation for this module is part of the file itself using the pod
(Plain Old Documentation) format.

Have fun.

Just a question:

- Does the name stay "polymorphism" or do I rename it to "Polymorphism" ?
  This module is very closed to Perl, this is because I name it
  without uppercase letter...

If you find this module useful or have some comments, let me now before
I upload it to CPAN...

Max.
-- 
for('sK{WtV_`_V^V_`rK7_KO[W_KrU[_K_O[O_E_;_=_O^U_?tKpU:^Os>O[_Uq=_=uGp9q&Us>pKO
[Up>6l=gNVKLVFKV>KV>f>Nj7WuWpKWu?_=<_G=_O=_NuU[sWqR_?rU[_O_>pK_KuGpIq\'[VqOp=?]
[W]7_=?]q=s>O[O[VK`CVMVKV?p?]u=q=7r=~~{=Z'=~/./g){print(("<>\n\\|/_ "=~/./sg)[(
$p=ord)>95?($p/16)x(3+$p%16):($p/8-4,$p&7)])}# www.DotCom.fr * max@DotCom.XX.fr


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

Date: 5 Oct 1998 12:04:13 GMT
From: roberto@toutatis.com (Roberto)
Subject: Reused lexically scoped variable not dereferenced in time
Message-Id: <roberto-ya02408000R0510981405070001@news.euronet.nl>

Using perl 5.005_02, the following script:

#!/usr/bin/perl -w

{
 my $test = handler(1);
}
print "done\n";

sub handler {
  my $i = $_[0];
  $i = bless \$i,'Test'; #reusing $i
}

END {
  print "ending\n";
}

package Test;

sub DESTROY {
  print "destroying\n";
}

prints out:
done
ending
destroying

DESTROY is called in the final cleanup of the program,
but any reference to the "Test" object is "out of scope"
before the call to print "done\n" is made, I'd say.
The problem is in reusing the variable $i in &handler.
The following works as I would expect:

#!/usr/bin/perl -w

{
 my $test = handler(1);
}
print "done\n";

sub handler {
  my $i = $_[0];
  my $test = bless \$i,'Test';
}

END {
  print "ending\n";
}

package Test;

sub DESTROY {
  print "destroying\n";
}

prints out:
destroying
done
ending

Is this a bug or a "feature"?

-- 
Roberto Bourgonjen
roberto@toutatis.net


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

Date: Mon, 5 Oct 1998 12:26:41 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Reused lexically scoped variable not dereferenced in time
Message-Id: <sik92f5h4u.fsf@cre.canon.co.uk>

Roberto <roberto@toutatis.com> wrote:
>   $i = bless \$i,'Test'; #reusing $i

This line creates a circular reference.  The scalar $i is a reference to
itself.  Perl's reference-counting memory manager can't tell when you're
no longer using $i, because $i's reference count is always at least 1.

When Perl shuts down the interpreter, it destroys all remaining objects,
regardless of whether they have reference counts.

If you want $i to be collected by Perl's memory manager, you'll have to
break the self-reference:

  undef $i;

See the section "Two-Phased Garbage Collection" in the perlobj manpage,
or the section "A Note on Garbage Collection" on p.299 of "Programming
Perl", second edition.

Aside: why doesn't Perl have a proper runtime garbage collector yet?

-- 
Gareth Rees


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

Date: 05 Oct 1998 12:41:10 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: RFC: "Build'n'Play" installation tool
Message-Id: <uu31js0bt.fsf@jimbosntserver.soundimages.co.uk>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:

> 
> Cool concept, but the name makes me cringe. How about 'Compile 'n' Go'? 
>

Well, not to be rude but how about "Dump 'N Go"? You know, Dump the
CD-ROM to disc 'N Go get a cup of coffee?? Just a thought.
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: Mon, 05 Oct 1998 08:42:57 -0400
From: John Porter <jdporter@min.net>
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <3618BED1.7BF0068C@min.net>

"Abigail" wrote:
> 
> Luckely, there's a cleaner way: closures. With (multiple) inheritance
> and autoloading.
> 
> package OO::Closures;
>...

Thank you, "Abigail"!

I was going to write this, but now I don't need to.  ;-)
Closures are The Right Way.  Kudos!

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


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

Date: Mon, 05 Oct 1998 12:15:46 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
Subject: Re: Survey Script
Message-Id: <3618AA62.91EE060A@whiterabbit.co.uk>

Addendum:

That should have been

http://www.whiterabbit.co.uk/survey_script.txt

(Thanks Larry)

Matt
--





Matt Pryor wrote:
> 
> [cc'd to Larry]
> 
> Well the url of the script in plain text format is
> http://www.whiterabbit.co.uk/review_script.txt - the link to this is
> provided with the output of the script though.
> 
> Matt
> 
> Larry Rosler wrote:
> > How about also posting the URL of the CGI program, or put the URL on the
> > HTML page, so anyone interested can learn from it?
> 
> --
> Matt's daily comic strip
> Porridge and Fartcakes
> http://www.whiterabbit.co.uk/cartoons

-- 
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons


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

Date: Mon, 5 Oct 1998 12:04:49 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: using sendmail with accents in a cgi?
Message-Id: <sipvc75i5a.fsf@cre.canon.co.uk>

cdessimoz@swisscenter.ch wrote:
> I'm trying to make a CGI which would be able to send mails from a
> form.  How to use accents as i h or ` (indeed, my text would be in
> french!).

You need to use MIME (Multipurpose Internet Mail Extensions; see RFC1521
and RFC1522) to send e-mail messages containing accented characters.
One possibility would be to send these message headers (ISO-8859-1 is
ISO Latin 1):

  Content-Type: text/plain; charset=ISO-8859-1
  Content-Transfer-Encoding: quoted-printable

and use the CPAN module MIME::QuotedPrint to convert your form data into
quoted-printable for transfer.

-- 
Gareth Rees


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

Date: Mon, 05 Oct 1998 11:17:13 GMT
From: grueni@stuttgart.netsurf.de (Andreas Grueninger)
Subject: Re: What is the maining of "Bare word"
Message-Id: <3618aaae.11278747@news.lf.net>

I would say the problem is in the variables. Obviously you would like
to have variables with quoted values.
Reactivate the two variables with the following and change the script
in the lower part to use again these two variables.

from:
>#$PPNS=$h{\"PARENT_NS_HOST\"};
>#$PHOST=$h{\"GLOBAL_NS_HOST\"};
to:
my $buf=q(");
my $PPNS="PARENT_NS_HOST";
$PPNS="$buf$PPNS$buf";
my $PHOST="GLOBAL_NS_HOST";
$PHOST="$buf$PHOST$buf";



---------------------------
Andreas Grueninger

PRIVATE: grueni@stuttgart.netsurf.de
 OFFICE: grueninger@lfl.bwl.de
---------------------------


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

Date: Mon, 05 Oct 1998 12:05:41 GMT
From: francisb@my-dejanews.com
Subject: Win32::Perl update/suggestion
Message-Id: <6vacml$b3t$1@nnrp1.dejanews.com>

I noticed that whenever my SQL() call contained a constant or function, the
results of the Data() call were comming back wrong. For example, "Select 0,
Name, convert(char(8),ECG_DateTime,108)" would return the results of the
convert, in this case a date string in both the first and third result fields.
It turns out that even a simple "select 0, Name, 10" would return "10, name,
10" in the result set. The problem lies in the fact that the updateResults
subroutine in odbc.pm is not designed to handle fields that do not have an
associated column name. I have made the following change to assign temporary
field names to any such field.

sub updateResults{
    my ($self, $Error, @Results) = @_;

    undef %{$self->{'field'}};

    ClearError($self);
    if ($Error){
        SetError($self, $Results[0], $Results[1]);
        return ($Error);
    }

	# in case there are any fields that have no names, give them names
	$fieldnum = 0;
	foreach(@Results){
		if (@Results[$fieldnum]==""){
			@Results[$fieldnum]= $fieldnum."fldsub";
		}
		$fieldnum++;
	}


    @{$self->{'fnames'}} = @Results;


    foreach (0..$#{$self->{'fnames'}}){
        s/ +$//;
        $self->{'field'}->{${$self->{'fnames'}}[$_]} = $_;
    }
    return undef;
}

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

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

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