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 > foo because it wasn't really important. If the $track var in that example is >undefined then it > will throw an error, right? So I don't see how writing it that way (aside from the >nicer split, > which I'll also be doing in my next rewrite but at least I thought of it before >someone had to > show me :-) will improve matters... >
The main difference is the position of my. You set it out of the loop while it is here in the loop. That's why $artist, $album and $track is undefined at the beginning of every loop again. (I also changed a little bit the regex from /\/// to m:/: what I assume to be more readable, but that isn't very important ) $foo was anything I didn't care much, but "$foo" eq $foo is always right and it's simpler to read, write and even quicker > > 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") > > 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 still don't quite get the whole "our"/"local" think yet. Still workin' on >that. % % Oh, and > I have always problems to explain it. > > No problem; I'll get there. > > 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 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). For OOP take a look to Damian Conway's books. Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]