[22211] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4432 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 20 14:06:06 2003

Date: Mon, 20 Jan 2003 11:05:11 -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           Mon, 20 Jan 2003     Volume: 10 Number: 4432

Today's topics:
    Re: A Good Perl Developing Enviroment (Sara)
        ANSWER: Re: OT: TOFU, jeopardy and spoilers <tassilo.parseval@post.rwth-aachen.de>
    Re: Arrays. What don't I get? (Tad McClellan)
        Confused - Fork - Thread - Ithread - Ahhhh... <LaoTzu@TaoTeChing.co.uk.us>
    Re: Creating standalone application <Ingo_Wiarda@web.de>
        Directly handling file descriptor <sun_tong@users.sourceforge.net>
    Re: Directly handling file descriptor (Anno Siegel)
    Re: Directly handling file descriptor <nobull@mail.com>
        Formatted printing question (Jesse Sheidlower)
    Re: got me foxed <david@morgmein.tk>
    Re: How can a SMTP mail be deleted from a Unix mailbox  <donal.k.fellows@man.ac.uk>
    Re: little-endian convert to big endian <jurgenex@hotmail.com>
        Newbie - "Nobody" in sender heading? <camerado@camerado.com>
    Re: Newbie - "Nobody" in sender heading? <jurgenex@hotmail.com>
        OO perl : object containing ref to other object (Paul Masquelier)
    Re: OO perl : object containing ref to other object <ubl@schaffhausen.de>
    Re: OO perl : object containing ref to other object <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: OO perl : object containing ref to other object (Ben Morrow)
    Re: OO perl : object containing ref to other object (tî'pô)
    Re: OO perl : object containing ref to other object (tî'pô)
    Re: OO perl : object containing ref to other object (tî'pô)
        OT: TOFU, jeopardy and spoilers <uri@stemsystems.com>
        Perl Question btam01@ccsf.edu
    Re: Perl Question (Helgi Briem)
    Re: Perl Question <jurgenex@hotmail.com>
    Re: Perl Question <LaoTzu@TaoTeChing.co.uk.us>
    Re: Perl Question <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Jan 2003 07:36:13 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: A Good Perl Developing Enviroment
Message-Id: <776e0325.0301200736.400b1b91@posting.google.com>

kcline17@hotmail.com (Kevin Cline) wrote in message news:<ba162549.0301192123.7b8b731e@posting.google.com>...
> genericax@hotmail.com (Sara) wrote in message news:<776e0325.0301190841.634bce0c@posting.google.com>...
> > "A. Fuentes" <alvarof2@hotmail.com> wrote in message news:<iz4W9.43403$aG4.2586200@twister.austin.rr.com>...
> > > Fellow Perl Netters:
> > > 
> > > I have a newbie question:
> > > 
> > > What would be a good Perl Developing Enviroment for
> > > managing and developing Perl projects?
> > > (Visual Developer Studio-like)
> > > 
> > > Any suggestions will be appreciated.
> > > 
> > > Thanks in advance,
> > > 
> > > A. Fuentes
> > > 512-297-9937
> > 
> > Some people "emacs" an environment. It runs in Perlmode, and you can
> > open various windows to do OS and compiling tasks. I like it for
> > editing and the syntax highlighting is nice, but I still just go to an
> > eterm for everything else, probably out of my own ignorance of the
> > power of emacs.
> 
> Just M-x shell and M-x perldb.

Thanks Kevin good tip- I'm already using it!

-Gx


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

Date: 20 Jan 2003 17:44:45 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: ANSWER: Re: OT: TOFU, jeopardy and spoilers
Message-Id: <b0hcid$e7s$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Uri Guttman:






[ spoiler space ]

















> i was browsing a tv show newsgroup the other day and i had forgotten
> about how important spoiler space is. spoilers are when you mention a
> critical or surprise plot element. if someone hadn't seen the episode
> yet (broadcast time delays and all) seeing a spoiler can ruin the
> show. the entire group enforces the rule that those posts have spoiler
> in their subject and plenty of blank (or spoiler) lines before the
> actual spoiler itself. this has an interesting and positive side
> effect. you almost never see top posting!! you can't do the jeopardy
> style of the reply at the top with a spoiler and THEN spoiler space
> below. :)

But it doesn't feel quite right in the context of this group. Where is
the spoiler space going to end up? Before the quoted material (as in
this post)? Makes no sense, because the OP might have already been read
previously. Between the quoted material and the reply? Well, that would
just be like top-posting. To get the context, you need to continually
scroll.

> so you see some very long threads that are very readable all the way
> through. there is proper editing of quotes, no signatures are left,
> attributions are left, etc.
> 
> so it is possible for a group to educate its readers as to better reply
> formatting and editing. i don't know the volume of the tv/movie groups
> but i do know the regulars are hard core. we get way too many newbies
> who don't know perl nor usenet.
> 
> so maybe we should adopt a spoiler style. if you answer a post with
> useful info, add 'ANSWER' to the subject and add spoiler space before
> the answers. forcing everyone here to finally read top down will
> encourage them to write that way too.

[ spoiler space ]























Now putting it in between. Hmmh. You know, Uri, your suggestion is the
best way to make every other group consider us 'peculiar' (even more
peculiar than we already are by the fact that we are using Perl). No, I
am not convinced. ;-)

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Mon, 20 Jan 2003 08:13:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Arrays. What don't I get?
Message-Id: <slrnb2o0vn.pc5.tadmc@magna.augustmail.com>

wrk <wkrempa@erols.com> wrote:
> Tad McClellan wrote:
>> wrk <wkrempa@erols.com> wrote:
>> > Anno Siegel wrote:

>> >> This clown
>> >> did about everything wrong that can be wrong in a Usenet posting,

>> > Why don't you educate me and tell  me what was wrong with my posting .
                   ^^^^^^^^^^
                   ^^^^^^^^^^

It now appears that you were not sincere about that.

Lying to people is likely to annoy them greatly.


>> For other things to avoid, see:
>>
>>       http://mail.augustmail.com/~tadmc/clpmisc.shtml


> Thanks Tad,


I'm insulted that you imply that I'm gullible enough to believe that.

We asked you to not top-post, you said thanks and then top-posted.

We asked you to not full quote, you said thanks and then full quoted.

We asked you to not send stealth Ccs, you said thanks and then stealth Cc'd.

You've used up all of your chances, so long.


   *plonk*


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


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

Date: Mon, 20 Jan 2003 13:11:26 -0500
From: "Lao Tzu" <LaoTzu@TaoTeChing.co.uk.us>
Subject: Confused - Fork - Thread - Ithread - Ahhhh...
Message-Id: <NLWW9.25820$F_3.15270@news.bellsouth.net>

I have a script that works as expected, but I would like to make it better.
I parses my mbox file and validates e-mail address with a MX lookup.  I
realize that this is not 100% effective, but I am doing this less to block
spam and more to learn better perl technique.

The script puts all e-mail addresses in a hash.
Then it uses "while" to process he entire hash.
It splits the e-mail address by the "@".
- my($name,$domain) = split"@", $key;
- It uses Net::DNS to see if a MX record exists for $domain.

It return either a 0 or a 1. 1 means that the MX exists and 0 means it does
not.

My question is, where should I look so that I can write the script so it can
do multiple MX lookups at once ?
I have been reading a bit about threads, and everything I have read so far
says to stay away.

I am lost and would appreciate any assistance anyone can offer.

Thanks.







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

Date: Mon, 20 Jan 2003 17:20:00 +0100
From: Ingo Wiarda <Ingo_Wiarda@web.de>
Subject: Re: Creating standalone application
Message-Id: <b0h7gq$p7n9v$1@ID-40614.news.dfncis.de>

Daby wrote:

> Nevermind, found one - perl2exe. Not free
> "Daby" <daby55@NOSPAM.com> wrote in message
> news:b0fm9f$v85$1@newsg2.svr.pol.co.uk...
>> Are there any free tools for doing this, or cheap ones :)? I`ve come
> across
>> PerlApp which is part of the $190 ActiveState PDK. 

You could try http://perlbin.sf.net which is free.
 I managed to create several executables, though it required some handwork. 
Basically it does some of the things B.Goldberg suggested earlier.

BTW, you will have to get a free version of the perl.dll, as you cannot 
simply package the one from ActivestatePerl (at least as far as I 
understand Perl & AS-Licensing). At CPAN you will find several without 
restricting licenses. (I used the Siemens-Compile)

Also, wether you use perl2exe, PerlApp or perlbin, you probably will want to 
make sure that the modules you integrate in your Programm are free to use - 
eg, some optional parts of Perl/Tk are not covered by the Perl license 
iirc.

Ingo



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

Date: 20 Jan 2003 12:38:25 -0500
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Directly handling file descriptor
Message-Id: <sa8k7gzbu26.fsf@suntong.personal.users.sourceforge.net>

Hi, 

I'm wondering how Perl can handle file descriptor directly, like
what bash's doing: 

echo asdb 3>/dev/tty >&3

In another word, how can I read/write to system file descriptor, not
a previously-opened file number? The following is what I've been
trying, but none of them work. Thanks for your help.

$ perl -e 'print {3} "test\n"' 3>/dev/tty

$ perl -e 'open(FH,"<&=3"); print FH "test\n"' 3>/dev/tty

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


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

Date: 20 Jan 2003 18:30:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Directly handling file descriptor
Message-Id: <b0hf82$4cc$1@mamenchi.zrz.TU-Berlin.DE>

* Tong *  <sun_tong@users.sourceforge.net> wrote in comp.lang.perl.misc:
> Hi, 
> 
> I'm wondering how Perl can handle file descriptor directly, like
> what bash's doing: 
> 
> echo asdb 3>/dev/tty >&3
> 
> In another word, how can I read/write to system file descriptor, not
> a previously-opened file number? The following is what I've been
> trying, but none of them work. Thanks for your help.
> 
> $ perl -e 'print {3} "test\n"' 3>/dev/tty

Where is that from?

> $ perl -e 'open(FH,"<&=3"); print FH "test\n"' 3>/dev/tty
                      ^
That opens FH for reading.  If you want to use it in print(), you must
open it for writing.

Next, if an open() gives you trouble, you *must* check its return value:

    perl -e 'open(FH,">&3") or die $!; print FH "test\n"' 3 > /dev/ttyp2

gives me a "Bad file descriptor...", which seems to indicate that my
shell doesn't provide fd3 in this way.  I don't know what yours does,
but this is a shell problem, not a Perl problem.

Anno


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

Date: 20 Jan 2003 18:45:13 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Directly handling file descriptor
Message-Id: <u9znpv8xty.fsf@wcl-l.bham.ac.uk>

* Tong * <sun_tong@users.sourceforge.net> writes:

> Hi, 
> 
> I'm wondering how Perl can handle file descriptor directly, like
> what bash's doing: 
> 
> echo asdb 3>/dev/tty >&3
> 
> In another word, how can I read/write to system file descriptor, not
> a previously-opened file number? The following is what I've been
> trying, but none of them work. Thanks for your help.
> 
> $ perl -e 'open(FH,"<&=3"); print FH "test\n"' 3>/dev/tty

Er, close but trivial typo...

 $ perl -e 'open(FH,">&=3"); print FH "test\n"' 3>/dev/tty

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 20 Jan 2003 13:12:18 -0500
From: jester@panix.com (Jesse Sheidlower)
Subject: Formatted printing question
Message-Id: <b0he62$o73$1@panix2.panix.com>

I'm trying to do some formatted printing in Perl, and
while I assume that what I'd like to do is easy, I've
been having trouble finding the right tools to do 
what I need.

Basically, I'd like to print out information from a database
onto letter or A4 paper such that each sheet can be split into
four quarters, each roughly 4" x 6". 

Each _quarter_ of the page should look something like:

---------------------------------------
|NAME                          SUBJECT|
|                                     |
|                                     |
|                                     |
|              TITLE                  |
|                                     |
|                                     |
|                                     |
|                                     |
|DATE                              FOO|
---------------------------------------

such that Subject and Foo are right-justified and Title is
center-justified. Also, in order to fit four of these on a
standard sheet of paper, it needs to print out lengthwise (so
that each quarter would be 4 1/4" x 5 1/2" on letter-size
paper). Finally, each such quarter-page slip is its own, so
text from one shouldn't spill over into another; yet if there
are more than four slips, there need to be additional pages,
one page for every four entries.

I looked at PostScript::TextBlock, but as far as I can tell
you can't specify either justification or lengthwise printing
with this. I also wasn't sure how to handle the multipage
printing.

I am, obviously, not very knowledgable about printing and 
layout so I apologize if I'm missing something very obvious.

Thanks.

Jesse Sheidlower


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

Date: Mon, 20 Jan 2003 18:27:27 +0000
From: David Sparkmunster <david@morgmein.tk>
Subject: Re: got me foxed
Message-Id: <3nco2v8k7lquoko75joqo6j2mah2orckn4@4ax.com>

On Sun, 19 Jan 2003 05:03:18 GMT, "Bill Smith" <wksmith@optonline.net>
wrote:

>I think you browser expects a page to display when it links to your CGI
>page.  Why not output a page which says that the file has been updated?

I did as you suggest and the whole thing worked perfectly. I'm most
grateful, thanks and to everyone who replied.


Lesson learnt:
The web browser is not happy simply to trigger a cgi but requires some
output that it can display.

David







------------------------------------
David Thorpe

See my photo portfolio of royalty free pictures:
http://www.rebelartist.com/seller/dthorpe

See my theatre
The Surrey Stick Figure Theatre Of Death at:
http://www.c-cat.demon.co.uk/theatre/


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

Date: Mon, 20 Jan 2003 16:30:35 +0000
From: "Donal K. Fellows" <donal.k.fellows@man.ac.uk>
Subject: Re: How can a SMTP mail be deleted from a Unix mailbox by a script?
Message-Id: <3E2C242B.5EBC9CF1@man.ac.uk>

lvirden@yahoo.com wrote:
> According to Markus Elfring <Markus.Elfring@web.de>:
>: This request's subject is the deletion of messages in the file "mbox".
> The second problem is even worse, in my opinion.  That is the factor of file
> locking.  Each mail program is free to (and appears to) make use of what
> its author(s) deem as most useful file locking.  Of course, if one's
> mail files are on NFS, then some file locking schemes are less successful
> than others.  But if an additional utility to, say, delete messages, were
> to be written, the author needs to account for the locking styles of ANY
> program which might update that box, so as not to lose messages.

Indeed, this is sufficiently nasty that I'd suggest doing everything using POP
or IMAP if the mailbox is accessible via that route!  At least then you could
use the assumption that someone has configured the delivery software and mailbox
access software to work together in terms of details like locking.  (If they
haven't... <FX: shiver of fear and loathing>)  Remote mail access protocols may
well suck, but at least they are defined protocols...

Donal.
-- 
Donal K. Fellows   http://www.cs.man.ac.uk/~fellowsd/   donal.fellows@man.ac.uk
-- Thanks, but I only sleep with sentient lifeforms. Anything else is merely
   a less sanitary form of masturbation.
                    -- Alistair J. R. Young <avatar-usenet@arkane.demon.co.uk>


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

Date: Mon, 20 Jan 2003 16:31:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: little-endian convert to big endian
Message-Id: <xvVW9.32$dU.3@nwrddc01.gnilink.net>

bin wrote:
> Is there any script can convert little endian ASCII file to
> Big-endian file?

One ASCII character is only 8 bits large, i.e. an ASCII file is just a
stream of single bytes.
There is no little endian or big endian for ASCII files.

jue




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

Date: Mon, 20 Jan 2003 18:15:47 GMT
From: CAMERADO <camerado@camerado.com>
Subject: Newbie - "Nobody" in sender heading?
Message-Id: <3E2C3C93.8DEE778A@camerado.com>

Hi--

I bet you've heard this one before, but I 'm not a big perl wizard, all
I know is that my mailing list manager uses Perl and whenever I send out
an automated mailing it says "Nobody"/ in the sender heading...

Can anybody tell me where / how to fix this in the script?

Thanks a lot,

JR
Camerado




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

Date: Mon, 20 Jan 2003 18:18:11 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie - "Nobody" in sender heading?
Message-Id: <D3XW9.531$PR2.528@nwrddc02.gnilink.net>

CAMERADO wrote:
> Can anybody tell me where / how to fix this in the script?

I just answered your question in "the other NG".
If you do mulit-posts then please see for yourself how to collect all the
replies.

jue




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

Date: 20 Jan 2003 06:35:26 -0800
From: paulmasquelier@yahoo.com (Paul Masquelier)
Subject: OO perl : object containing ref to other object
Message-Id: <62bd92c7.0301200635.3b18dd46@posting.google.com>

Hello,

I am trying to do very simple OO stuff, but I don't succeed :
an object containing a reference to another object;
this is what I tried :
I use a Book object, and tried to contain a ref to a chapter object in
it :

1) Chapter.pm :

package Chapter;

use strict;

sub new 
{
my $this = shift;
my $name = shift;
my $self = {
	NAME => $name,
	};

bless $self, $this;
}

sub Name
{
my $this = shift;
my $name = ${$this}{NAME};
return $name;
}

1;

2) Book.pm :

package Book;

use strict;

use Chapter;

sub new
{
my $this = shift;
my $bookname = shift;
my $chaptername = shift;

my $chapter = Chapter->new($chaptername);

my $self = {
	NAME => $bookname,
	CHAPTER => $chapter,
	};

bless $self, $this;
}

sub GetBookName
{
my $self = shift;

return ${$self}{NAME};
}

sub GetChapter
{
my $self = shift;

return ${$self}{CHAPTER};
}

1;

3) test.pl :

use strict;

use Chapter;
use Book;


#my $chapter = Chapter->new("FirstChapter");
#print $chapter->Name(); # ok, works

my $book = Book->new("bookname", "chaptername");

print $book->GetBookName();

my $chapter = Book->GetChapter(); # should return a blessed reference,
but doesn't !
print $chapter->Name();

1;

Apparently, the blessed reference that should be returned by
${$self}{CHAPTER} is lost !
This seems to me the most logical way to contain an object in another
object.

Has anyone done this before ?
Or does anyone know how to solve this problem ?
What is the standard way in Perl for an object containing another
objects ref ??
I couldn' find anything in 'Perl Cookbook'.

Thanks for any help,
Paul


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

Date: Mon, 20 Jan 2003 15:41:16 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <b0h52d$8ud$1@news.dtag.de>

Paul Masquelier wrote:
> Hello,
> 
> I am trying to do very simple OO stuff, but I don't succeed :
> an object containing a reference to another object;
> this is what I tried :

> sub Name
> {
> my $this = shift;
> my $name = ${$this}{NAME};

Try this and expand it to other similar cases in your code:
my $name = $this->{NAME};

Read up on Perl references, especially on dereferencing.

Bye,
->malte

-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: Mon, 20 Jan 2003 16:31:34 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <newscache$n4r09h$15d$1@news.emea.compuware.com>

Paul Masquelier wrote (Monday 20 January 2003 15:35):

> Hello,
> 
> I am trying to do very simple OO stuff, but I don't succeed :
> an object containing a reference to another object;
> this is what I tried :
> I use a Book object, and tried to contain a ref to a chapter object in
> it :
> 
> 1) Chapter.pm :
> 
> package Chapter;
> 
> use strict;


Setting things to strict is good.
Including warnings is even better:

    use warnings;

> sub new
> {
> my $this = shift;
> my $name = shift;
> my $self = {
> NAME => $name,
> };
> 
> bless $self, $this;
> }


If you have defined a Name method, then why don't you use it?
Together with a more legible indentation, I would have written this as:

    sub new {
        my $this = shift;
        my $name = shift;
        my $self = {};
        bless $self, $this;  # now he knows he's got methods
        $self->name($name);  # methods and variables prefer lower case
    }


> sub Name
> {
> my $this = shift;
> my $name = ${$this}{NAME};
             ^^^^^^^^^^^^^^

You are mixing up things here. $this is an hash ref. The way to access the 
NAME key is:

    my $name = $this->{name};  # again mapped to lc

Note also, that you never actually have set $this->{NAME}. Hence it will 
always return undef. (Oh, I forgot, you cut corners in the new() method.... 
Well then, don't cut corners like that anymore. It forces you to remember 
what you did in your other methods/subs. Let the object take care of 
itself.) 
So if you drop the short cut from new(), applied some indentation and 
lowercase mapping, you might better rewrite this as:

    sub name {
        my $this = shift;
        if ( @_ ) {  # any arguments?
           $this->{name} = shift;  # store the first arg
        }
        return $this->{name};  # and return whatever is in there
    }



I've only skimmed the rest of your code. But I would reckon that if you go 
the same way with Book.pm as with Chapter.pm your script should run fine. 
If not, just come back with your questions.

HTH.

-- 
KP



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

Date: Mon, 20 Jan 2003 16:21:44 +0000 (UTC)
From: mauzo@ux-ma160-15.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: OO perl : object containing ref to other object
Message-Id: <b0h7mo$4j7$1@wisteria.csv.warwick.ac.uk>

Malte Ubl <ubl@schaffhausen.de> wrote:
>Paul Masquelier wrote:
>> Hello,
>> 
>> I am trying to do very simple OO stuff, but I don't succeed :
>> an object containing a reference to another object;
>> this is what I tried :
>
>> sub Name
>> {
>> my $this = shift;
>> my $name = ${$this}{NAME};
>
>Try this and expand it to other similar cases in your code:
>my $name = $this->{NAME};
>
>Read up on Perl references, especially on dereferencing.

This is good advice, but doesn't solve the problem.

~% perl -le'$r = {}; bless $r, "Pack"; $a = {k => $r}; print ${$a}{k}' 
Pack=HASH(0xd653c)

${$a}{k} appears to be correct: it's a logical generalization of %{$a}.
$a->{k} is still clearer, of course.

However...

>> 3) test.pl :
>> 
>> use strict;
>> 
>> use Chapter;
>> use Book;
>> 
>> 
>> #my $chapter = Chapter->new("FirstChapter");
>> #print $chapter->Name(); # ok, works
>> 
>> my $book = Book->new("bookname", "chaptername");
>> 
>> print $book->GetBookName();
>> 
>> my $chapter = Book->GetChapter(); # should return a blessed reference,

Here is your problem. You mean $book->GetChapter(); .

You may want to add a line
ref $self or croak "GetChapter is an object not a class method";
to GetChapter (croak is a very useful variant on die: perldoc Carp).

>> but doesn't !
>> print $chapter->Name();
>> 
>> 1;

Ben


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

Date: Mon, 20 Jan 2003 18:29:34 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <pn8o2vogn4bj5orv6qa34f780oubpfrct3@4ax.com>

Paul Masquelier bravely attempted to attach 108 electrodes of
knowledge
to the nipples of comp.lang.perl.misc by saying:
>my $chapter = Book->GetChapter(); # should return a blessed reference,
 my $chapter= $book->GetChapter(); 
You're asking for a chapter for a specific book so you need to call it
on a blessed object. 
Inside GetChapter when you do 
my $self = shift; 
You get the string Book, instead of the blessed $book object you
created.

Try getting used to debugging (perl -d test.pl), I helps you see what
perl sees and not what you expect to see.



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

Date: Mon, 20 Jan 2003 18:30:14 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <ov8o2vohq9p1uh1k4vcbci8pdhf1ed8gqa@4ax.com>

Malte Ubl bravely attempted to attach 23 electrodes of knowledge
to the nipples of comp.lang.perl.misc by saying:
>> my $name = ${$this}{NAME};
>
>Try this and expand it to other similar cases in your code:
>my $name = $this->{NAME};
>
>Read up on Perl references, especially on dereferencing.

${$this}{NAME} works too. 
Personally I find it less readable but to each their own.


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

Date: Mon, 20 Jan 2003 18:35:21 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: OO perl : object containing ref to other object
Message-Id: <519o2v0i7duahuufrqd34h0kkv6r03f8tc@4ax.com>

Koos Pol bravely attempted to attach 84 electrodes of knowledge
to the nipples of comp.lang.perl.misc by saying:
>Paul Masquelier wrote (Monday 20 January 2003 15:35):
>    sub new {
>        my $this = shift;
>        my $name = shift;
>        my $self = {};
>        bless $self, $this;  # now he knows he's got methods
>        $self->name($name);  # methods and variables prefer lower case
                                   ^^^^^^^^
Says who? it's a matter of taste and has nothing to do with the OP
problem.

	 return $self;
# Otherwise you don't get an object from new, you get a $name
>    }

>
>> sub Name
>> {
>> my $this = shift;
>> my $name = ${$this}{NAME};
>             ^^^^^^^^^^^^^^
>
>You are mixing up things here. $this is an hash ref. The way to access the 
>NAME key is:
>
>    my $name = $this->{name};  # again mapped to lc

Either syntax works. I prefer -> too BTW.

>I've only skimmed the rest of your code. But I would reckon that if you go 
>the same way with Book.pm as with Chapter.pm your script should run fine. 
>If not, just come back with your questions.

It doesn't, he called GetChapter as a static method rather than a
regular one.


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

Date: Mon, 20 Jan 2003 17:11:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: OT: TOFU, jeopardy and spoilers
Message-Id: <x7iswjwxu8.fsf@mail.sysarch.com>


i was browsing a tv show newsgroup the other day and i had forgotten
about how important spoiler space is. spoilers are when you mention a
critical or surprise plot element. if someone hadn't seen the episode
yet (broadcast time delays and all) seeing a spoiler can ruin the
show. the entire group enforces the rule that those posts have spoiler
in their subject and plenty of blank (or spoiler) lines before the
actual spoiler itself. this has an interesting and positive side
effect. you almost never see top posting!! you can't do the jeopardy
style of the reply at the top with a spoiler and THEN spoiler space
below. :)

so you see some very long threads that are very readable all the way
through. there is proper editing of quotes, no signatures are left,
attributions are left, etc.

so it is possible for a group to educate its readers as to better reply
formatting and editing. i don't know the volume of the tv/movie groups
but i do know the regulars are hard core. we get way too many newbies
who don't know perl nor usenet.

so maybe we should adopt a spoiler style. if you answer a post with
useful info, add 'ANSWER' to the subject and add spoiler space before
the answers. forcing everyone here to finally read top down will
encourage them to write that way too.

:)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Mon, 20 Jan 2003 07:48:00 -0800
From: btam01@ccsf.edu
Subject: Perl Question
Message-Id: <Pine.HPX.4.44.0301200744580.5542-100000@hills.ccsf.cc.ca.us>

I'm curious about the current state of Perl.  Do companies still use Perl
for CGI?  Is Perl becoming obsolete in the CGI world?  I've noticed a lot
web sites using asp.

-Bill



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

Date: Mon, 20 Jan 2003 16:11:09 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl Question
Message-Id: <3e2c1f5c.1429688162@news.cis.dfn.de>

On Mon, 20 Jan 2003 07:48:00 -0800, btam01@ccsf.edu wrote:

>I'm curious about the current state of Perl.  

Alive and kicking.

>Do companies still use Perl for CGI? 

Yes, and for lots and lots of other things too.
Mostly other things.

>Is Perl becoming obsolete in the CGI world? 

No.

>I've noticed a lot web sites using asp.

You can use Perl with ASP.  Apples and oranges.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Mon, 20 Jan 2003 16:41:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl Question
Message-Id: <VEVW9.14$PR2.11@nwrddc02.gnilink.net>

btam01@ccsf.edu wrote:
> I'm curious about the current state of Perl.  Do companies still use
> Perl for CGI?  Is Perl becoming obsolete in the CGI world?  I've
> noticed a lot web sites using asp.
>
> -Bill

I'm curious about the current state of the French language. Do companies
still use French for Newspapers? Is French becoming obsolete in the
Newspaper world? I've noticed a lot of newsstands are selling magazines.

Yes, the language is very much alive, both in newspaper and non-newspaper
applications.
And you can use French in magazines, too.

jue





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

Date: Mon, 20 Jan 2003 11:57:26 -0500
From: "Lao Tzu" <LaoTzu@TaoTeChing.co.uk.us>
Subject: Re: Perl Question
Message-Id: <uGVW9.25481$F_3.13713@news.bellsouth.net>


<btam01@ccsf.edu> wrote in message
news:Pine.HPX.4.44.0301200744580.5542-100000@hills.ccsf.cc.ca.us...
> I'm curious about the current state of Perl.  Do companies still use Perl
> for CGI?  Is Perl becoming obsolete in the CGI world?  I've noticed a lot
> web sites using asp.
>
> -Bill
>
For using perl on the web, read up at:
http://perl.apache.org

Sure you can use CGI, but CGI with mod_perl is much much faster!





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

Date: 20 Jan 2003 17:40:59 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl Question
Message-Id: <u9el77afdg.fsf@wcl-l.bham.ac.uk>

helgi@decode.is (Helgi Briem) writes:

> On Mon, 20 Jan 2003 07:48:00 -0800, btam01@ccsf.edu wrote:
> 
> >I've noticed a lot web sites using asp.
> 
> You can use Perl with ASP.  Apples and oranges.

That's a really bad metaphor.

Apples and oranges are very similar things in many ways and are
definitely comparible in most contexts.

Indeed if I didn't already know that you were saying that one
shouldn't compare Perl and ASP then I'd think, from you metaphor, you
were saying the exact opposite.

Perhaps "Apples and retail" would be better?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


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