Re: Contructing a dir. tree
From: Paul Lalli (ittyspam_at_yahoo.com)
Date: 06/10/04
- Next message: David K. Wall: "Re: parsing file through an array"
- Previous message: Jim Gibson: "Re: parsing file through an array"
- In reply to: JR: "Re: Contructing a dir. tree"
- Next in thread: Joe Smith: "Re: Contructing a dir. tree"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 10 Jun 2004 11:17:32 -0400
On Thu, 10 Jun 2004, JR wrote:
> Paul Lalli <ittyspam@yahoo.com> wrote in message news:<20040609153546.J8971@dishwasher.cs.rpi.edu>...
> > On Wed, 9 Jun 2004, JR wrote:
> >
> > > my $info = undef;
> >
> > That's a completely worthless initialization.
> > my $info;
> > does the same thing.
>
> I know it does. It doesn't hurt anything either, to set it to undef;
> in fact, it makes is completely clear to even the novice programmer
> that it is, in fact, undefined.
I respectfully disagree. The 'hurt' this can cause is to lead a novice
Perl programmer to think that variables must be initialized, that they are
not undef by nature.
> > > my $count = 0;
> >
> > That's an almost-completely worthless initialization
> > my $count;
>
> I know dude. The reason I set it to zero is for the same reason I set
> $info to undef. Christ!
And now you seem to be getting upset without cause. If you are not
willing to have your programs critiqued, allow me to suggest this is
perhaps not the best forum for you to post your programs, whether they are
originals or solutions to another poster's problems.
Again, while *you* may know the initialization is not needed, a novice
programmer may not. Especially one who comes from a C background where
the initialization is needed. That is why I sent my post, for the
learners. Not every reply to your message is intended soley for you.
Welcome to usenet.
> > > $info = qq|Parent Folder: $_\n{\n Some text here about "$arr[0]"\n|;
> > > $info .= qq| Child Folder: bar1\n|;
> > > $info .= qq| {\n|;
> > >
> > > my $indent = 6;
> > > $info .= qq|\nFile element: Some text about "$arr[$#arr]"\n|;
> > > $info .= "=" x 39, "\n";
> > > print $info;
> >
> > I'm not at all clear as to why you're building up this (potentially huge)
>
> Potentially huge? I wonder just how huge a directory path is likely
> to be. Hmm, now I'm nitpicking just the way you have been. Sorry
> about that.
Do you have any idea what the OP meant by "Some text here"? For all we
know, he could be printing the Gutenberg Bible for every directory level.
So yes, I think "potentially huge" is a valid description.
> > scalar to be printed only once at the end. Why are you not just printing
> > each line of text as it comes? Can you explain what benefit is to be
> > gained by storing all this text in memory before printing?
> >
> > Paul Lalli
>
> The o/p used an array to capture the information; I used a scalar.
> Perhaps he needs to use the scalar or array, whichever, later in the
> program. I realize he could just print the thing, instead of storing
> it and then printing it! I'm just throwing out a script to the o/p
> that he can either use or not, one that resebmles to some degree his
> original script.
My comments were not about the OP's post, nor about how well your post
answered his question. I was simply wondering if there was any reason you
made the design decision of storing all text in memory before printing it.
There is no sarcasm in that sentence, btw. I am always willing to believe
there are reasons for things I don't understand - this was a case of my
asking if you had such a reason.
> Rather than lambaste my script, why don't you show us what you have,
> in the way of a solution? That would be a far more useful way for you
> to spend your time. You are clearly a vastly superior programmer, so
> put your talents to use.
Again, welcome to usenet. I was not 'lambasting' your script, I was
critiquing it and asking for further explanation. This is a community.
The community is best served when many people make their comments and
opinions known. The idea that any solution posted should just be left out
in the world without any critiques is a poor one at best. Code should be
critiqued and evaluated no matter where it comes from, nor why. That is
how to best serve both the OP as well as any one else reading who may have
similar questions.
Paul Lalli
- Next message: David K. Wall: "Re: parsing file through an array"
- Previous message: Jim Gibson: "Re: parsing file through an array"
- In reply to: JR: "Re: Contructing a dir. tree"
- Next in thread: Joe Smith: "Re: Contructing a dir. tree"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|