[23310] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5530 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 19 18:05:51 2003

Date: Fri, 19 Sep 2003 15:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 19 Sep 2003     Volume: 10 Number: 5530

Today's topics:
    Re: A (probable) error in perltoot  ( perl5/5.8.0/pod/p (Anno Siegel)
    Re: create new file (Anno Siegel)
        debugging <darius_fatakia@yahoo.com>
    Re: debugging (Tad McClellan)
        GD object problem (Vesselin Baev)
    Re: How can I comment out a large block of perl code? (Anno Siegel)
    Re: Intermediate Page w/ CGI Script (Pete Butler)
    Re: kill command in a perl script <tzz@lifelogs.com>
    Re: Newbie Question: Could someone show me how to imple <Borniac_1@hotmail.com>
        Newbie: Perl 5.8.0 not working in Red Hat 8.0 <no.bryanah.trash.email@bullwinkle.net>
    Re: Newbie: Perl 5.8.0 not working in Red Hat 8.0 <dwilga-MUNGE@mtholyoke.edu>
    Re: Newbie: Perl 5.8.0 not working in Red Hat 8.0 <no.bryanah.trash.email@bullwinkle.net>
        perl man pages in xemacs <samj@austarmetro.com.au>
    Re: Perl regular expression does not work on 5.8.0 <stefan.rupp@inform-ac.com>
    Re: referencing, closures, classes <x12code-del@del-yahoo.com>
    Re: referencing, closures, classes <x12code-del@del-yahoo.com>
    Re: referencing, closures, classes <uri@stemsystems.com>
    Re: referencing, closures, classes <uri@stemsystems.com>
    Re: referencing, closures, classes <mpapec@yahoo.com>
    Re: referencing, closures, classes <x12code-del@del-yahoo.com>
    Re: referencing, closures, classes <x12code-del@del-yahoo.com>
    Re: referencing, closures, classes <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Sep 2003 18:50:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: A (probable) error in perltoot  ( perl5/5.8.0/pod/perltoot.pod, line number 756 )
Message-Id: <bkfj4u$9sq$2@mamenchi.zrz.TU-Berlin.DE>

Himanshu Garg <himanshu@gdit.iiit.net> wrote in comp.lang.perl.misc:
> Dear Perl Programmers,
>      
>     I tried out the code given in :-
> 
> http://www.perldoc.com/perl5.8.0/pod/perltoot.html#Aggregation
>   
>     The following line :- 
> 
> printf "%s is really %s.\n", $him->name, $him->fullname;
> 
>     gives the following output :- 
> 
> Tommy is really Fullname=HASH(0x804c9b8).
> 
>     This happens because fullname returns an object reference as follows :-
> 
> sub fullname 
> {
>     my $self = shift;
>     return $self->{FULLNAME};
> } 
> 
>     Therefore the line should probably be :-
> 
> printf "%s is really %s.\n", $him->name, $him->fullname->as_string;
> 
>     Please correct me if I am wrong.

Looks like you're right.  Not a biggie, but you could send in a patch.

Anno


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

Date: 19 Sep 2003 19:42:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: create new file
Message-Id: <bkfm7k$b94$2@mamenchi.zrz.TU-Berlin.DE>

Cody Hess  <cjh2011@columbia.edu> wrote in comp.lang.perl.misc:
> Bob Walton wrote:
> > Cody Hess wrote:
> > 
> >> I want my script to create new files when opening a filehandle to a 
> >> file that doesn't exist.
> >>
> >> open FILE, "> new_file.dat" or die "Failed: $!";
> >>
> >> I believe this should happen automatically, but I get the error
> >>
> >> Failed: No such file or directory at ./write_file_experiment.pl line 3.
> >>
> >> Is there something wrong with my filehandle?  Is there another way to 
> >> create a new file if it doesn't already exist?
> >>
> > 
> > Your code, run verbatim, works fine on my system (Windoze 98SE, AS Perl 
> > build 806).  You don't say what your OS and Perl versions are -- would 
> > you happen to be in a directory where the user you are running doesn't 
> > have directory write (or maybe read) priviledge (and on an OS where that 
> > is possible)?
> > 
> I run perl 5.8 on Mac OS X (10.1).  The directory is writable to the 
> owner.  I've tried running the script as root and I get the same error 
> message.

The only way the message "No such file or directory" makes sense with
an open for write is when the path contains a directory component that
doesn't exist.  Your path is a straight file name -- strange.

Note that Macs often have case-insensitive file systems.  These sometimes
show unusual effects, tough I don't see how that could account for what
you're seeing.

Anno


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

Date: Fri, 19 Sep 2003 13:41:08 -0700
From: "superfly2" <darius_fatakia@yahoo.com>
Subject: debugging
Message-Id: <bkfpl5$9aq$1@news.Stanford.EDU>

just a general debugging question:
i'm writing a script (web script) and i keep getting back the infamous
Error message:
Premature end of script headers: new_batch_convert.pl

I have "use strict" and "use warnings", and I check the error log but that
message is ALL i get. i'm trying to comment out different regions to get it
to work that way but i was wondering if there were any other suggestions for
approaching this. Basically, I had a working script that i modified and now
i don't know where my bug is. If it was a missing semicolon or parentheses,
I would get some line number reference right?

thanks!




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

Date: Fri, 19 Sep 2003 16:12:35 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: debugging
Message-Id: <slrnbmmsa3.htc.tadmc@magna.augustmail.com>

superfly2 <darius_fatakia@yahoo.com> wrote:
> just a general debugging question:
> i'm writing a script (web script) and i keep getting back the infamous
> Error message:
> Premature end of script headers: new_batch_convert.pl


Try running it from the command line.


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


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

Date: 19 Sep 2003 12:10:53 -0700
From: vesko_baev@abv.bg (Vesselin Baev)
Subject: GD object problem
Message-Id: <cb413b7.0309191110.3f5bf86f@posting.google.com>

Hello to All,
Baybe I'm not alone with this message error when I started the script:
Can't locate loadable objest for module GD...
I've noticed that in the forum there is a lot of people with the same
problem but I did't find the solution for it!
We using Linux SuSE, and we have the latest version of Perl. We
installed the GD package and we have also the libgd files (I've
checked that)!
What we have to do!

Thanks!
Vesselin Baev


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

Date: 19 Sep 2003 19:23:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I comment out a large block of perl code?
Message-Id: <bkfl3b$b94$1@mamenchi.zrz.TU-Berlin.DE>

Dan Jacobson  <jidanni@jidanni.org> wrote in comp.lang.perl.misc:
> $ perldoc -q 'How can I comment out a large block of perl code?' says
> to use =begin comment text, =end comment text, but I find the =end

[snip]

> Wait, he meant to say use a =cut instead of =end comment text!

It's probably a bug worth reporting.

> Please report a bug for me, my bugs just go into a black hole.

What do you mean?  Some Cabale?  Someone in the perlbug process is throwing
out your reports?

Your reports have the same chance to be accepted than everybody else's.
An accompanying patch increases the chance considerably.  Otherwise,
doc patches are sometimes worked into the next version of the doc without
tracing each change back to every reporter.  Have you looked if your
suggestions have been incorporated this way?

Anno


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

Date: 19 Sep 2003 13:28:14 -0700
From: pmbutler@attbi.com (Pete Butler)
Subject: Re: Intermediate Page w/ CGI Script
Message-Id: <9b766f0.0309191228.68078363@posting.google.com>

"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message news:> 
> <announcement mode=public-service>
> In case you hadn't noticed, CGI questions aren't generally welcomed
> here (c.l.p.misc) unless they have some specifically Perl content -
> and that's irrespective of whether you're programming them _in_ Perl.
> perlfaq9 has further pointers.
> </>

Sorry about that.  It occurred to me that my question was probably
only tangentially Perl-related, but that moment of realization came
about an hour or two after I'd posted . . .

If I annoyed anybody else with the question, please accept my
apologies.  I know better now; it won't happen again.

-- Pete Butler


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

Date: Fri, 19 Sep 2003 17:36:12 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: kill command in a perl script
Message-Id: <4nwuc4cvg3.fsf@lockgroove.bwh.harvard.edu>

On Wed, 17 Sep 2003, krahnj@acm.org wrote:

> Not that I'm against using modules.  :-) I just like to know what
> all my options are.

I absolutely agree.  In this case, your options are to either use
Proc::ProcessTable or to write alpha-quality software.  Using ps -ef
and trying to manually parse the output is an absolutely horrible
solution, and please understand I say that because I've done it, not
to criticize your efforts.

Ted


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

Date: Fri, 19 Sep 2003 19:56:49 GMT
From: Borniac <Borniac_1@hotmail.com>
Subject: Re: Newbie Question: Could someone show me how to implement options
Message-Id: <190920032157499822%Borniac_1@hotmail.com>

In article <a73jmvs5btf518kdfb25tr3c2gcdu0saqd@4ax.com>, Bart Lateur
<bart.lateur@pandora.be> wrote:

> Andreas Kahari wrote:
> 
> >use Getopt::Std;
> 
> My preferred way it to use Getopt::Long, like this:
> 
>  use Getopt::Long;
>  GetOptions(\my %opt, 'id=i', 'verbose', 'foo=s');
> 
>  # see what we got:
>  use Data::Dumper;
>  print Dumper \%opt;
> 
> use like:
> 
>  perl test.pl -verbose -id=123 -foo=abc FILES
> 
> You may use single or double hyphens.

Sorry It took so long
I thank everybody for pointing me in the right direction
I 'am using use Getopt::Long


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

Date: Fri, 19 Sep 2003 14:25:34 -0600
From: "Bryan Hilterbrand" <no.bryanah.trash.email@bullwinkle.net>
Subject: Newbie: Perl 5.8.0 not working in Red Hat 8.0
Message-Id: <bkfoo2$kn4$1@terabinaries.xmission.com>

I installed Red Hat 8.0 on an old system that I had laying around, and the
Red Hat installer put Perl 5.8.0 on my system.  Whenever I try to run Perl,
it fails.  For example:

[root@teeny root]# perl -V
Perl v5.6.0 required--this is only v5.8.0, stopped at
/usr/lib/perl5/5.8.0/Exporter.pm line 3.
Compilation failed in require at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/Config.pm line 2.
BEGIN failed--compilation aborted at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/Config.pm line 2.
Compilation failed in require.
BEGIN failed--compilation aborted.

[root@moose root]# perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi
    [...]

[root@moose root]# which perl
/usr/bin/perl


I searched all over trying to answer this one, but I couldn't find any
solutions for this particular problem.

Random details that probably don't matter: 300MHz AMD K6-2 with 64MB memory
and a 2GB hard drive.  Red Hat Linux release 8.0 (Psyche).

Thank you for any help!
Bryan




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

Date: Fri, 19 Sep 2003 17:21:39 -0400
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: Newbie: Perl 5.8.0 not working in Red Hat 8.0
Message-Id: <dwilga-MUNGE-C0271E.17213919092003@nap.mtholyoke.edu>

In article <bkfoo2$kn4$1@terabinaries.xmission.com>,
 "Bryan Hilterbrand" <no.bryanah.trash.email@bullwinkle.net> wrote:

> I installed Red Hat 8.0 on an old system that I had laying around, and the
> Red Hat installer put Perl 5.8.0 on my system.  Whenever I try to run Perl,
> it fails.  For example:
> 
> [root@teeny root]# perl -V
> Perl v5.6.0 required--this is only v5.8.0, stopped at
> /usr/lib/perl5/5.8.0/Exporter.pm line 3.
> Compilation failed in require at
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi/Config.pm line 2.
> BEGIN failed--compilation aborted at
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi/Config.pm line 2.
> Compilation failed in require.
> BEGIN failed--compilation aborted.

This looks like the perl binary is probably 5.6.0, whereas it's looking 
in a directory which contains 5.8.0 modules.

I suggest you check your PATH environment variable (`whereis perl`) to 
see if there are multiple copies of the binary lurking on your machine.

It would also be a good idea to download the Perl source and re-compile 
it from scratch. I, and others, have had lots of problems with RedHat's 
stock RPMs of Perl.

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: Fri, 19 Sep 2003 15:49:50 -0600
From: "Bryan Hilterbrand" <no.bryanah.trash.email@bullwinkle.net>
Subject: Re: Newbie: Perl 5.8.0 not working in Red Hat 8.0
Message-Id: <bkftm3$llj$1@terabinaries.xmission.com>


"Dan Wilga" <dwilga-MUNGE@mtholyoke.edu> wrote in message
news:dwilga-MUNGE-C0271E.17213919092003@nap.mtholyoke.edu...
>
> This looks like the perl binary is probably 5.6.0, whereas it's looking
> in a directory which contains 5.8.0 modules.
>
> I suggest you check your PATH environment variable (`whereis perl`) to
> see if there are multiple copies of the binary lurking on your machine.
>
> It would also be a good idea to download the Perl source and re-compile
> it from scratch. I, and others, have had lots of problems with RedHat's
> stock RPMs of Perl.

Thanks for the info, Dan!

I did the "whereis perl", and it just returned:

[root@moose root]# whereis perl
perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz

So it looks like the installation is messed up.  If I build it myself, which
RPMs should I remove?   There is a bunch of them:

[root@moose root]# rpm -qa | grep perl
perl-Parse-Yapp-1.05-26
perl-libxml-perl-0.07-25
perl-XML-Grove-0.46alpha-21
perl-5.8.0-55
perl-DateManip-5.40-27
perl-HTML-Parser-3.26-14
perl-URI-1.21-3
perl-XML-Parser-2.31-12
perl-XML-Dumper-0.4-22
perl-libxml-enno-1.02-25
perl-XML-Twig-3.05-3
mod_perl-1.99_05-3
perl-Filter-1.28-9
perl-CPAN-1.61-55
perl-HTML-Tagset-3.03-25
perl-libwww-perl-5.65-2
perl-XML-Encoding-1.01-20

Should I just remove perl-5.8.0-55 and compile/install stable.tar.gz that I
downloaded from cpan.org?  Or should I remove them all, and then find all
the Perl libraries and install them?

Bryan




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

Date: Fri, 19 Sep 2003 21:56:03 GMT
From: Sam <samj@austarmetro.com.au>
Subject: perl man pages in xemacs
Message-Id: <3F6B7D24.2060400@austarmetro.com.au>

Hello
how can I use xemacs to read perl man pages. currently I do
bach$man <PerlPackageName>

another point:
in the text of a perl doc "See section <SectionName> at the bottom of 
this document.
is there a pod reader where <SectionName> would hyperlinked to that 
location in that documnet for easy of navigation?
even pod2html does not do this.

any hint is appriciatee

thanks



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

Date: Fri, 19 Sep 2003 22:02:50 +0200
From: Stefan Rupp <stefan.rupp@inform-ac.com>
Subject: Re: Perl regular expression does not work on 5.8.0
Message-Id: <bkfndb$5b4$07$1@news.t-online.com>

Good evening,

Thanks for the answer!

Christian Winter schrieb:
> in some circumstances the [^\s] doesn't work in the standard
> distribution of perl shipped with redhat 9, due to some utf8
> bug. Upgrading your perl version or disabling utf8 support
> for your locale should solve this.

How do I 'disable utf8 support' in RH 9?  I'm more used to Debian, so 
I'm unfamiliar with 'The RedHat way'.

The other option, to update perl, would be to go to perl 5.8.1 beta, 
which I'd rather avoid.  I'd need libdb-4.1.so for that as well.

Regards,
Stefan



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

Date: Fri, 19 Sep 2003 13:06:37 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: Re: referencing, closures, classes
Message-Id: <jigmmv8mjbnujibkvj9o34qmcbkdu4ktbi@4ax.com>

>From: "David K. Wall" <usenet@dwall.fastmail.fm>
>Subject: Re: referencing, closures, classes
>Date: Fri, 19 Sep 2003 17:32:09 -0000
>
>Eric Schwartz <emschwar@pobox.com> wrote:
>
>> David McDivitt <x12code-del@del-yahoo.com> writes:
>>> The problem I was having was the "return sub" syntax. This is
>>> what does the closure.
>> 
>> No it's not.  Remember, there is no "return sub" syntax.  There's 
>> "sub {...}", which declares an anonymous sub, and returns a
>> reference to it, and 'return <foo>', which returns a value or list
>> of values. It's the sub {...} declaration which creates the
>> closure; the return just returns the subref which the sub {...}
>> creates. 
>
>I don't see why anonymous subroutines were used to introduce 
>closures, anyway.  Other than the syntax used to call the subroutine, 
>what difference does it make whether the subroutine has a name or 
>not?  As Matija Papec pointed out, Damian Conway's _Object Oriented 
>Perl_ book defines a closure as just a subroutine that refers to one 
>or more lexical variables declared outside the subroutine itself.  
>But Larry uses anonymous subroutines in the Camel (p 259 in the 3rd 
>ed), too.
>
>Using anonymous subroutines to *introduce* closures seems like 
>unnecessary obfuscation to me.  Introduce the idea with as few 
>complications as possible, *then* show how to make them more 
>powerful.
>
>Or am I missing something?

I plan on getting that book soon as I've finished the one I have. I
appreciate Eric Roode mentioning it. Being new to the language I don't know
what things are most significant at this point and what I don't need to
worry about, in the context of learning one thing after another. Dialog here
has been helpful. Just as Perl is not a strongly typed language, people seem
less anal retentive about it in general, which is refreshing.



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

Date: Fri, 19 Sep 2003 13:14:38 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: Re: referencing, closures, classes
Message-Id: <7ghmmvogdadrca30mf5iuf0un17rim5ja1@4ax.com>

>From: Uri Guttman <uri@stemsystems.com>
>Subject: Re: referencing, closures, classes
>Date: Fri, 19 Sep 2003 17:53:38 GMT
>
>>>>>> "DKW" == David K Wall <usenet@dwall.fastmail.fm> writes:
>
>  DKW> I don't see why anonymous subroutines were used to introduce 
>  DKW> closures, anyway.  Other than the syntax used to call the subroutine, 
>  DKW> what difference does it make whether the subroutine has a name or 
>  DKW> not?  As Matija Papec pointed out, Damian Conway's _Object Oriented 
>  DKW> Perl_ book defines a closure as just a subroutine that refers to one 
>  DKW> or more lexical variables declared outside the subroutine itself.  
>  DKW> But Larry uses anonymous subroutines in the Camel (p 259 in the 3rd 
>  DKW> ed), too.
>
>you can't generate multiple closures with named subs. you can only have
>one sub with a given name so it is a limiting factor.
>
>{ my $foo = 4 ;
>
>sub bump_foo { return ++$foo}
>
>}
>
>that is a closure by your rule (and many others). i prefer to use the
>term where anon subs are used since closures are meant to carry private
>data around. the above code really just hides $foo (even if it is
>carried by the sub in its pad).
>
>in fact there was a bug report on p5p regarding named closures not being
>garbage collected properly whereas anon ones worked fine.
>
>  DKW> Using anonymous subroutines to *introduce* closures seems like 
>  DKW> unnecessary obfuscation to me.  Introduce the idea with as few 
>  DKW> complications as possible, *then* show how to make them more 
>  DKW> powerful.
>
>  DKW> Or am I missing something?
>
>writing a better section on it would be better. you need anon subs to
>make closures useful. but you should cover anon subs and code refs first
>and later introduce closures. then you teach the stuff incrementally.
>
>as for the 'return sub' syntax, how many times have we seen print <<FOO
>and newbies think <<FOO is a part of the print syntax? again, that is
>the result of cargo cult learning and bad books.

You expressed an excellent point and one I've had a problem with -
recognizing what's significant as I go along. The book is so badly written,
with things seeming significant which are not, I may have to read a portion
several times.



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

Date: Fri, 19 Sep 2003 19:54:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: referencing, closures, classes
Message-Id: <x7znh0pn9f.fsf@mail.sysarch.com>

>>>>> "DM" == David McDivitt <x12code-del@del-yahoo.com> writes:

  >> From: Uri Guttman <uri@stemsystems.com>

  >> writing a better section on it would be better. you need anon subs to
  >> make closures useful. but you should cover anon subs and code refs first
  >> and later introduce closures. then you teach the stuff incrementally.
  >> 
  >> as for the 'return sub' syntax, how many times have we seen print <<FOO
  >> and newbies think <<FOO is a part of the print syntax? again, that is
  >> the result of cargo cult learning and bad books.

  DM> You expressed an excellent point and one I've had a problem with -
  DM> recognizing what's significant as I go along. The book is so badly
  DM> written, with things seeming significant which are not, I may have
  DM> to read a portion several times.

so when will you burn this waste of wood pulp and get a better book?

uri

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


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

Date: Fri, 19 Sep 2003 19:56:09 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: referencing, closures, classes
Message-Id: <x7wuc4pn6u.fsf@mail.sysarch.com>

>>>>> "DM" == David McDivitt <x12code-del@del-yahoo.com> writes:

  DM> I plan on getting that book soon as I've finished the one I
  DM> have. I appreciate Eric Roode mentioning it. Being new to the
  DM> language I don't know what things are most significant at this
  DM> point and what I don't need to worry about, in the context of
  DM> learning one thing after another. Dialog here has been
  DM> helpful. Just as Perl is not a strongly typed language, people
  DM> seem less anal retentive about it in general, which is refreshing.

you'd be better off dropping that book altogether and getting
others. you keep mentioning its weaknesses and no strengths so why keep
reading it? and closures are not something to teach early or so lightly.

uri

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


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

Date: Fri, 19 Sep 2003 21:57:46 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: referencing, closures, classes
Message-Id: <qcnmmvksjl71r9iisfsuhp7cq3acqqds0r@4ax.com>

X-Ftn-To: David McDivitt 

David McDivitt <x12code-del@del-yahoo.com> wrote:
>Here is what the book says:
<snip>
>string containing the word "fly", which was passed to the first call to
>"animalInFood". Similarly, the closure invoked at line 22 prints a string
>containing the word "frog", which was passed to the second call to
>"animalInFood".
>********************************
>
>I don't know what I'm supposed to get from this. It is not well written in
>my opinion and I fail to get the point of even reading it. Closures seem to
>be very important however, and understanding closures would seem to help one
>understand classes, too. Thanks

Nope, closures have nothing to do with classes, moreover they are not
crucial for understanding an OO paradigm. However, they are usually
portrayed as possible choice for object currier(in practice hashes are far
often used). 
So, for what on the earth are they useful? Closures offer complete data
encapsulation so you can't directly change object attributes like with
hashrefs,

use SomeClass;
my $object = SomeClass->new;
#access via hash reference
$object->{attribute} = 'Breaking the law!';

There is an excelent book on OO Perl writen by Damian Conway where you can
dive in all object details(IMO, best thing beside "Perl Cookbook").


-- 
Matija


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

Date: Fri, 19 Sep 2003 15:46:26 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: Re: referencing, closures, classes
Message-Id: <foqmmv8i4n5ak9i06t9bcmut3k3gclh1kd@4ax.com>

Pretty quick!

>From: Uri Guttman <uri@stemsystems.com>
>Subject: Re: referencing, closures, classes
>Date: Fri, 19 Sep 2003 19:54:36 GMT
>
>>>>>> "DM" == David McDivitt <x12code-del@del-yahoo.com> writes:
>
>  >> From: Uri Guttman <uri@stemsystems.com>
>
>  >> writing a better section on it would be better. you need anon subs to
>  >> make closures useful. but you should cover anon subs and code refs first
>  >> and later introduce closures. then you teach the stuff incrementally.
>  >> 
>  >> as for the 'return sub' syntax, how many times have we seen print <<FOO
>  >> and newbies think <<FOO is a part of the print syntax? again, that is
>  >> the result of cargo cult learning and bad books.
>
>  DM> You expressed an excellent point and one I've had a problem with -
>  DM> recognizing what's significant as I go along. The book is so badly
>  DM> written, with things seeming significant which are not, I may have
>  DM> to read a portion several times.
>
>so when will you burn this waste of wood pulp and get a better book?



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

Date: Fri, 19 Sep 2003 16:00:47 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: Re: referencing, closures, classes
Message-Id: <bqqmmv885ok1h0j3knch4thoscel5b5034@4ax.com>

>From: Uri Guttman <uri@stemsystems.com>
>Subject: Re: referencing, closures, classes
>Date: Fri, 19 Sep 2003 19:56:09 GMT
>
>>>>>> "DM" == David McDivitt <x12code-del@del-yahoo.com> writes:
>
>  DM> I plan on getting that book soon as I've finished the one I
>  DM> have. I appreciate Eric Roode mentioning it. Being new to the
>  DM> language I don't know what things are most significant at this
>  DM> point and what I don't need to worry about, in the context of
>  DM> learning one thing after another. Dialog here has been
>  DM> helpful. Just as Perl is not a strongly typed language, people
>  DM> seem less anal retentive about it in general, which is refreshing.
>
>you'd be better off dropping that book altogether and getting
>others. you keep mentioning its weaknesses and no strengths so why keep
>reading it? and closures are not something to teach early or so lightly.

The closure part was brief. Classes weren't too bad. The rest of the book
looks like gravy. Databases, threads, etc. I spent $85 on the book. Too
much, yes, but I wanted something immediately. Why were there not many Perl
books at Barnes and Noble?

The book does have good stuff such as a whole chapter on fundamental flow
charting. It was not UML. I hate stick people. There as another good chapter
on the history of computers and the internet. The book is not a total waste.



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

Date: Fri, 19 Sep 2003 21:24:04 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: referencing, closures, classes
Message-Id: <x7brtgpj4b.fsf@mail.sysarch.com>

>>>>> "DM" == David McDivitt <x12code-del@del-yahoo.com> writes:

  DM> The closure part was brief. Classes weren't too bad. The rest of
  DM> the book looks like gravy. Databases, threads, etc. I spent $85 on
  DM> the book. Too much, yes, but I wanted something immediately. Why
  DM> were there not many Perl books at Barnes and Noble?

way expensive. sounds like it tries to cover too much and in too little
depth. a classic flaw in language books.

  DM> The book does have good stuff such as a whole chapter on
  DM> fundamental flow charting. It was not UML. I hate stick
  DM> people. There as another good chapter on the history of computers
  DM> and the internet. The book is not a total waste.

what? this covered flow charts? what kind of dumb shit is that? anyone
who is learning perl and knows any other language should not need flow
charts. ewwwww!!

see if this is on books.perl.org and write the appropriately scathing
review.

uri

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


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

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


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