Janek, et al -- ...and then Janek Schleicher said... % % David T-G wrote at Wed, 12 Jun 2002 19:42:46 +0200: % ... % > % > In this limited context, yes. I wouldn't usually declare them all up front. % % Well, I thought you never do (as I know you're not a beginner any more)
Oh, I'm still a beginner, all right :-) % But I know, some beginners do, so I was a little bit provocant :-) Good enough. % ... % > requirements. If you look at % > % > my ($artist, $album, $track) ; % > while (<>) % > { % > ($artist, $album, $track) = split(/\//); % > if ( $track eq "foo" ) % > ... % > } % % 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... % % > % I think, that it is my obligation to warn you % > % that use strict; use warnings; wasn't made for that way. % > % > Now, them's fightin' word, pardner! Into the street! % % I like fightings :-) *grin* % But to say the truth, it reads harder than I meant it. % Of course, TMTWTDI, as I only wanted to say, it could be dangerous this way. I understand, and I appreciate it. % % Again it was adressed to the many beginners outside the world. % In fact, curiously, to understand why strict declarations and warnings are needed, % it's more a problem to java beginners than to perl beginners. % I still try to understand why :-) Interesting. One more reason not to know java, I guess ;-) <ducks> % ... % > integrate single-case undef logic into the loop, no? % % Yep, you're right! % (But taking my way would force every loop an undef, doesn't it :-)) True :-) Hey, I could just undef *everything* between iterations and then I'd have a higher probability of finding one, eh? :-) % % > 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... % Well, when you'll understand the philosphy you never want to go back. % It's like the difference between the goto statement from BASIC and subroutines. I imagine and I can't wait :-) I need to really "get" OOP, too. % % > At the moment I'm storing then in a hash as ... % > some more data" subroutine, which will also scope them locally. % % That sounds good. Yay :-) % % > % > Given all of that (*whew*), does it sound like I'm on the right track or instead still Not Getting % > It Even If TMTOWTDI? % % Yes. % There are only some ways with a little bit more adventure :-) Good enough; one of these days I can lace up my boots and head off on a rewrite then. As long as I'm not doing this flat-out incorrectly right now it'll do. % % (It's like with doubled code which one is an alert signal for me too for various reasons.) Yeah. I already have some of that and am trying to work them out to a single subroutine. % % Cheerio, % Janek 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!
msg25988/pgp00000.pgp
Description: PGP signature