Janek, et al --

...and then Janek Schleicher said...
% 
% David T-G wrote at Wed, 12 Jun 2002 21:50:12 +0200:
% 
% > % I would try to write it as
% > % while (<>) {
% > %    my ($artist, $album, $track) = split m:/:;
% > %    if ($track eq $foo) {   # $foo eq "$foo" :-)
% > %       ...
% > %    }
% > % }
% > 
% > I don't see a difference here except that you're using a variable $foo where I 
threw in a constant
...
% 
% The main difference is the position of my.
% You set it out of the loop while it is here in the loop.

Ahhh...  Right; I did, indeed, miss that before.


% That's why $artist, $album and $track is undefined 
% at the beginning of every loop again.

So it is.

That brings up an older question which can be restated more clearly now:
is it better to have a "my" definition tightly inside a loop but thus
force looping through checking [at least] two other variables instead
of simply checking to see if either has changed and only looping
when necessary?  In my case, I currently check to see if the source
has changed and, if so, then kick off a new round of source checking
and path depth checking and the like; if it were undefined every time,
then I wouldn't be optimizing away those loops for some 90% of the run.


% 
% (I also changed a little bit the regex from /\/// to m:/: what
%  I assume to be more readable, but that isn't very important
% )

Well, readable is good, too, even in perl :-)


% 
% $foo was anything I didn't care much,

Right.


% but "$foo" eq $foo is always right
% and it's simpler to read, write and even quicker

Hmmm...  I don't follow you here, either.  Do you mean that the quoted on
the left compared to the unquoted on the right or is there a particular
reason you've compared $foo to itself?


% 
% > Interesting.  One more reason not to know java, I guess ;-) <ducks>
% 
% As alread Lenin said:
% You have to be an expert of the language of your enemies :-)
% (free translated from german: "Du musst die Sprache des Feindes beherrschen")

Heh :-)  Good point.


% 
% > Hey, I could just undef *everything* between iterations and then I'd have a higher 
probability of
% > finding one, eh? :-)
% 
% One, you didn't want it :-)
% You'll understand it when you'll understand the philosophy of my/our/local

I guess I'll have to work on that, then, because the undef and re-search
problem above seems the wrong way to do it.


% 
...
% > Interesting...  I just went to look for it in my 2e Camel book and can't find it 
(only my and
% > local).  Hmmm...
% 
% Take a look to the "Art of Computer Programming" by Donald Knuth.
% Nothing similar to Perl, but to Programming in general (without 'OOP').

I'm quite familiar with it, though not as freshly as when it was my
course textbook.


% 
% > I imagine and I can't wait :-)  I need to really "get" OOP, too.
% 
% If there's anybody who needs it hardcore,
% take a look to Modula-3 (again without OOP).

Ick.  I didn't like Modula-2 (and part of the reason to avoid Python
is because it depends on indentation for structure); I'd hate to see
Modula-3!


% 
% For OOP take a look to Damian Conway's books.

Ahhh...  A lead I can follow; thanks.


% 
% 
% Cheerio, 
% Janek

Aside from the loop semantics question above, which is only barely there,
we may be drifting off topic...  It's sufficient for me to go away and
read for a while, though I'd still be very much interested in further
pointers from those who wish to send them!


Thanks & HAND

:-D
-- 
David T-G                      * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: msg25993/pgp00000.pgp
Description: PGP signature

Reply via email to