Session Start: Tue Feb 27 14:39:23 2001 [14:39] *** Now talking in #topniche [14:39] -HelpBot- Welcome to Topniche IRC Webmaster Chat. Webmasters only please! [14:39] -HelpBot- Our url: http://www.weboverdrive.com/ [14:39] *** channel stats for #topniche:   +o: 1   -o: 2   +v: 0   total: 3 [14:40] -> *HelpBot* op #topniche helpone [14:40] *** HelpBot sets mode +o @FurBall [14:40] *** FurBall sets mode +o @TDavid [14:40] *** @FurBall changed topic to "Perl/CGI Week 3 Chat" [14:40] *** @FurBall changed topic to "Perl/CGI Week 3 Chat starts at 3 PM Eastern" [14:44] *** Itchy (itchmaster@24.70.215.1O46=) joined #topniche [14:44] cool 2 at once that might screw me up hehe [14:45] :-) [14:45] Itchy, I see your bestweek3 script... [14:45] nice!!! Well commented!!! [14:46] Thank you was having troubles this morning [14:46] I saw that. :-) [14:46] lol [14:47] Not to bad for a guy that never coded anything but html in his life tell I heard of your guy's school [14:47] :-) See.. it's not THAT difficult! :-) [14:47] And you handled the advanced statements QUITE well!!! [14:47] <@TDavid> 11 messages [14:47] <@TDavid> 0.0 rating [14:47] <@TDavid> Feb-27-01 02:28 PM [14:47] ala: $good= "good Morning" if ($hour < 12); [14:48] <@TDavid> i still wonder what that rating this is about! hehe [14:48] well.. that rating is now 10.0. :-) [14:48] To be honest, I have NO idea... :-) [14:48] thanks was wondering about that but it worked hehe [14:48] but I THINK if you were running a more "public" BBS, it would apply. :-) [14:48] still need to see if the good evening works tonight [14:49] :-) [14:50] <@TDavid> i keep thinking of that black sabbath zero the hero lol [14:50] <@TDavid> the song, that is :) [14:50] LOL [14:50] good song [14:50] <@TDavid> itchy it is exciting to see you getting into the code :)) that's what this is all about [14:51] <@TDavid> programming on the surface seems to be much more complex than it truly is :) [14:51] Yup I never was much intrested in anything before but i see what a person can do and it lite a fire in me :-) [14:51] ALRIGHT!! That's why we're here and doing this. :-) [14:52] *** FurBall sets mode +v +Itchy [14:52] <+Itchy> LOL and i was thinking the kind of money i person could make with good scripts hehe [14:52] :-) Well.. there is support for those scripts though.. :-) [14:52] <@TDavid> automate those human tasks, that's the key :) [14:53] <+Itchy> Yup thats the key I think [14:53] <@TDavid> writing scripts to distribute for the public is an entirely different animal [14:53] Absolutely! [14:53] <+Itchy> Well I was looking at your $500 link script and thought if he sells that 10 times thats $5000 [14:53] Oh Tdavid, should this chat be logged? [14:54] And does that log get posted somewhere? [14:54] <@TDavid> yes, you send to me and I post at script school :) [14:54] <+Itchy> Yup we need to beable to look back heheh [14:55] K.. consider it logged. :-) [14:55] umm.. you want or not want timestamps for each line? [14:55] <@TDavid> yeah timestamps are good [14:55] Good. :-) [14:55] <@TDavid> gives us a sense of timing lol [14:55] Consider em there. :-) [14:55] *** MadamZ (java@208.8.133.GD869=) joined #topniche [14:55] <@TDavid> welcome madamz [14:55] Ahh.. Kewll.. welcome MadamZ [14:55] <+Itchy> helps people remmeber what time to get here lol [14:55] <+Itchy> hi MadamZ hehe [14:56] ok [14:56] *** TDavid sets mode +v +MadamZ [14:56] <+MadamZ> very funny folks:) [14:56] <+MadamZ> thanks Furball [14:56] Yw. :-) [14:58] <@TDavid> somebody type the word "cookie" [14:58] cookie [14:59] <+Itchy> cookie [14:59] <+Itchy> "cookie" [14:59] <@TDavid> hehe [14:59] <@TDavid> oops try again [14:59] <+Itchy> cookie [14:59] * @TDavid gives Itchy a cookie :) [14:59] <+Itchy> thanks lunch [15:00] <@TDavid> hehe got to eat i guess [15:00] :-) [15:00] <@TDavid> since we are talking today about if logic that is a perfect example [15:00] Ok.. according to my clock, it's 3 PM today... [15:00] <@TDavid> you type "cookie" and then voila! IRC spits out the cookie message [15:00] <+Itchy> MadamZ I joined your site today and never got a password ;-( [15:01] <+Itchy> cookie voila! [15:01] * @TDavid gives Itchy a cookie :) [15:01] <+MadamZ> Oh my are you the cybecop [15:01] <+Itchy> pornocop yup shhhhhhhhhh [15:01] <+MadamZ> lol [15:01] <+Itchy> lol [15:01] <+MadamZ> did you confirm yet [15:01] Ok... shall we get this chat started here? :-) [15:01] <@TDavid> now what if we want to only give itchy a chocolate chip cookie and everybody else an oatmeal cookie [15:01] <+Itchy> never got anything in my e-mail ;-( [15:02] <@TDavid> already started I thought :) [15:02] <+MadamZ> hummm [15:02] LOL [15:02] <+MadamZ> ok will do [15:03] <+Itchy> opps it's there now :-) [15:03] <@TDavid> if($name eq "itchy") { $cookie = 'chocolate chip'; } else { $cookie = 'oatmeal'; } [15:03] <@TDavid> now UNIX is casE SensItive so that wouldn't match itchy's nick [15:03] <@TDavid> if($name eq "Itchy") { $cookie = 'chocolate chip'; } else { $cookie = 'oatmeal'; } [15:04] <@TDavid> note the difference, very important when using an absolute comparsion operator [15:04] *** spaceman (java@64.228.106.zO96=) joined #topniche [15:04] also, note that since he is testing a string, he is using the eq operator. [15:04] welcome Spaceman [15:04] *** FurBall sets mode +v +spaceman [15:04] <+spaceman> hi [15:04] <@TDavid> if you want to do case insensitive comparisons you would use something called a regular expressions OR you would need to convert the string to all lowercase [15:05] <@TDavid> before testing it [15:05] We will be getting into regular expressions later on around week 5. [15:05] <@TDavid> now what if we want to give spaceman a fudge brownie, give itchy a chocolate chip cookie and everybody else an oatmeal cookie? [15:06] (stealing my line Tdavid. :-)) [15:06] <+spaceman> ummm brownie [15:06] <@TDavid> just don't steal my cookie! :) [15:06] LOL [15:06] <+Itchy> elsif? [15:06] any ideas? [15:06] In 1 itchy! [15:06] <@TDavid> what would be the code, Itchy, exactly [15:07] <+Itchy> min [15:07] <+spaceman> i read in TNB there was a CGI chat here did i miss it? [15:07] nope.. [15:07] it's starting right now.. [15:07] <@TDavid> this is it, spaceman :) [15:07] <+spaceman> cool [15:07] <@TDavid> if($name eq "Itchy") { $cookie = 'chocolate chip'; } else { $cookie = 'oatmeal'; } [15:07] we're going over logic. [15:07] in perl. [15:07] *** Slave (java@24.149.1.E1684=) joined #topniche [15:08] <@TDavid> that is the perl CGI code to test for if the name equals Itchy then give him a chocolate chip cookie and give everybody else an oatmeal cookie [15:08] *** Slave (java@24.149.1.E1684=) quit (QUIT: User exited) [15:08] welcome slave [15:08] <@TDavid> slave was enslaved by another channel it seems :) [15:09] <+Itchy> elsif($name eq "spaceman") {cookie = 'fudge brownie} [15:09] * @TDavid gives Itchy a cookie :) [15:09] LOL.. guess so... [15:09] *** spaceman_ (spaceman_1@64.228.106.Ya18=) joined #topniche [15:09] where does that elsif go in the code itchy? [15:09] *** +spaceman (java@64.228.106.zO96=) left #topniche [15:09] *** FurBall sets mode +v +spaceman_ [15:09] <+Itchy> after the else oatmeal ? [15:10] No. If it did, then it would never be gotten to. [15:10] It would find the else first and always run that code. [15:10] <+Itchy> oooo after if [15:10] <@TDavid> imagine the if as the beginning of a train and the else as the caboose [15:10] Perfect example! :-) [15:10] <@TDavid> er locomotive :) [15:11] <@TDavid> everything inbetween are the elsifs [15:11] the freight cars are the elsifs. :-) [15:11] <+Itchy> well that makes more sense to me [15:11] <@TDavid> which they would have spelled it "elseif" .. so that is an error to watch out for [15:11] <@TDavid> in php it is spelled that way [15:11] <+MadamZ> So what does the elsif do what is its function [15:11] <@TDavid> er, I WISH, not "which" as stated above [15:11] <@TDavid> to allow you more options in the comparison [15:12] Let's take the example again: [15:12] <@TDavid> if($name eq "Itchy") { $cookie = 'chocolate chip'; } else { $cookie = 'oatmeal'; } [15:12] *** Teq (java@206.42.161.h38=) joined #topniche [15:12] <+MadamZ> ok [15:12] <@TDavid> you only have 2 options there ... but we need to give spacman a "fudge brownie" [15:12] Hi guys [15:13] if ($name eq "itchy") { $cookie = 'chocolate chip';} elsif ($name eq "spaceman"} { $cookie = 'fudge brownie'; } else {$cookie = 'oatmeal';} [15:13] *** FurBall sets mode +v +Teq [15:13] <@TDavid> hi teq, welcome to the perl cgi week #3 course workshop [15:13] hi teq! [15:13] now, with this code, you have 3 options... [15:13] IF you are itchy, you get a chocolate chip cookie.... [15:13] else IF you are spaceman, you get a fudge brownie, [15:13] otherwise you get an oatmeal cookie. [15:14] <@TDavid> everyone understand this? questions? [15:14] <@TDavid> it is easy to confuse assignment and comparison operators [15:15] <@TDavid> this is assignment: = this is comparison: == (equal to number) eq (equal to string) [15:15] yes.. remember, IF you are testing a number Ie: if ($week == 3) is VERY different to if ($week = 3) [15:15] <@TDavid> if($week =3) will always be true, does everyone understand why? [15:16] <+spaceman_> no:) not fully [15:16] <@TDavid> because ANY assignment will always be true [15:16] <+spaceman_> k [15:16] <+Itchy> becfause it's set $week = 3 [15:16] <+Teq> Tom's newbie booster [15:16] <@TDavid> correct [15:17] Yup Itchy! [15:17] <+MadamZ> the = would make 3 but == would open it up other statments?? [15:17] the == would test to see if $week is equal to 3. [15:17] <@TDavid> the two equals now make the expression a comparison instead of an assignment [15:17] <+MadamZ> ik [15:17] <+MadamZ> ok that is [15:18] <@TDavid> but as furball mentioned the only time you use the two equals is when comparing numbers [15:18] YES... :-) [15:18] <@TDavid> for strings you use: eq [15:18] doing this: if ($name == "spaceman") will cause you to get a internal server error. [15:19] <@TDavid> why? [15:19] because it is a syntax error... [15:19] <@TDavid> not you, furball! [15:19] <@TDavid> hehe [15:19] SORRY. :-) *d'OH [15:19] * @TDavid takes away furball's cookie [15:20] <+Itchy> lol [15:20] <@TDavid> but do you folks understand WHY it is a syntax error? [15:20] <+Itchy> because space man not a number [15:20] <@TDavid> this is important because when all you see is a 500 error it is important to be able to find these bugs in your code [15:20] <+MadamZ> yelp [15:20] <@TDavid> good :) [15:21] Great! [15:21] <+Itchy> you mean like forgeting a ";" [15:21] <@TDavid> correct [15:21] That too. :-) [15:21] a tip here. [15:21] For remembering when to use eq and == [15:21] <@TDavid> now let's find the bugs in the following code there are several of them ... [15:21] if you have to use a ' or " after the operator, use the eq otherwise use == [15:21] <@TDavid> if($name ne "itchy") { $cookie = 'chocolate chip' } else { $cookie = 'oatmeal; } [15:22] <@TDavid> What are the errors: if($name ne "itchy") { $cookie = 'chocolate chip' } else { $cookie = 'oatmeal; } [15:22] <+Itchy> ne >eq [15:22] <@TDavid> that is one, correct [15:22] <+Itchy> 'chocolate cookie'; [15:23] <+Itchy> 'oatmeal'; [15:23] <+Itchy> eslif [15:23] <@TDavid> what are the errors? [15:23] <@TDavid> 1. ne - should be eq [15:24] <@TDavid> 2. missing terminator after 'chocolate chip'; [15:24] <+Itchy> ne needs to be eq next is missing ";" else needs to be elsif [15:24] correct on the ne and missing ';' but not the elsif... [15:24] why not? [15:24] <+Itchy> otameal missing ending' [15:25] correct. [15:25] <+Itchy> it's perl and not cgi [15:25] <@TDavid> 3. oatmeal missing closing quote 'oatmeal'; [15:26] are there any other errors in the code? [15:26] <@TDavid> Missing brackets are a common error too, but I didn't omit one of those in the buggy code above [15:26] <+Itchy> case of name [15:26] <@TDavid> very good! :) [15:26] <@TDavid> why is this a mistake? [15:26] <+Itchy> itchy does not = Itchy [15:27] <@TDavid> because ... ? [15:27] Why? [15:27] <+Itchy> it's not a regular [15:27] <+Itchy> expression [15:27] <@TDavid> nope [15:27] <@TDavid> anybody else have a guess? [15:27] <@TDavid> i mentioned why above [15:28] <+Itchy> because abousolute [15:28] <+spaceman_> becasue its case sensitive [15:28] and you alluded to it Itchy in what was wrong with it. [15:28] correct spaceman [15:28] <@TDavid> unix is caSe SeNsItiVe ... therefore 'itchy' does not equal "Itchy" [15:28] <@TDavid> these type of bugs in code are extremely difficult to find [15:29] amen... :-) [15:29] <+Itchy> thats why we have search and replace :-) hehe [15:29] LOL [15:29] <@TDavid> because perl will not throw a 500 over these type of errors [15:29] <@TDavid> great point :) [15:30] <@TDavid> ok are we ready to move onto the logical NOT ? [15:30] <@TDavid> we've talked about comparing for a condition, but how about comparing AGAINST a condition [15:31] <@TDavid> IE. what if we want to see if spaceman_ is NOT eating a fudge brownie? [15:31] <+MadamZ> if($name eq "Itchy") {$cookie ='chocolate chip';} [15:31] <+MadamZ> sorry is this right [15:31] yes it is MadamZ [15:31] <@TDavid> yes, that is correct [15:31] <+Itchy> $good= "Good Morning" if ($hour < 12); [15:32] <+Itchy> is that against? [15:32] <@TDavid> no, just a different way of writing the expression [15:32] <+Itchy> ;-( [15:32] no, that's an advanced way of saying if ($hour <12) {$good = "good Morning"; } [15:32] <@TDavid> like the same as saying: [15:33] <@TDavid> i will goto the store if my car has gas [15:33] <@TDavid> my car has gas so I'm going to the store [15:33] <+Itchy> ok [15:33] we already know how to test if something is EQUAL. What is the opposite of EQUAL? [15:34] <+Itchy> less then [15:34] <+Itchy> or more then [15:34] No [15:34] <+spaceman_> not equal [15:34] <+MadamZ> != [15:34] <@TDavid> IE. what if we want to see if spaceman_ is NOT eating a fudge brownie? How would the code look? [15:34] bingo spaceman. :-) [15:34] <+MadamZ> I think [15:34] and bingo MadamZ. :-) [15:34] <@TDavid> numbers: != strings: ne [15:35] so we want to see if spaceman 's cookie is NOT EQUAL to a fudge brownie... [15:35] <@TDavid> can a number be a string? [15:35] <+MadamZ> no [15:35] <@TDavid> anybody else? [15:36] Anyone? :-) [15:37] <+Itchy> lost [15:38] <@TDavid> $number1 = '4'; $number2 = 4; $total = $number1 + $number2; print $total; [15:38] <+MadamZ> modify ne is to check strings? [15:38] yes, ne is used to check if 2 strings are not equal to each other. [15:39] <@TDavid> itchy, im trying to show that numbers and strings are two separate entities and mixing them together can have undesireable results [15:39] <+Itchy> ok i'm looking [15:39] <@TDavid> 4 + '4' does not equal 8 [15:39] <@TDavid> it equals 5 ... or does it? [15:40] <+Itchy> still ='s 4 ? [15:41] <+MadamZ> + adds amount 1 to amount 2 but what is '4' [15:41] <+MadamZ> would'nt we have to determine '4' [15:42] how can a string have a numeric value? [15:42] does a string have a numeric value? [15:43] <+Itchy> does this have to do with rhs? [15:43] *** MadamZ (java@208.8.133.GD869=) quit (QUIT: User exited) [15:44] <@TDavid> any value in a variable is true (1) .. any empty value is false (0) [15:45] <@TDavid> perl will take care of numbers themselves in quotes or not in quotes, was my point [15:45] <@TDavid> but 4 + '4 days' does not equal 8 [15:45] <@TDavid> this is where we really need to go with it, because 4 + '4' still equals 8 [15:46] *** MadamZ (java@208.8.133.OM576=) joined #topniche [15:46] w/b MadamZ [15:46] *** FurBall sets mode +v +MadamZ [15:46] <+MadamZ> Kids Sorry [15:47] <+Itchy> 4+'4days doesn't =8 because of the numbers and charaters together of '4days'? [15:47] does everyone understand this concept? [15:47] <@TDavid> technically it doesn't, but we don't want to derail too much here [15:47] <@TDavid> perl has built in functionality to strip away the numbers from a string [15:48] <@TDavid> other languages often do not [15:48] the concept being that you can't mix numbers and strings. [15:48] *** Teq (java@206.42.161.h38=) quit (QUIT: User exited) [15:48] <+MadamZ> Baby is going ape again catch you friday [15:48] K... see you then MadamZ... andif you have questions, please feel free to ask them on the board. [15:48] <+Itchy> bye;-?( [15:48] <@TDavid> we'll go back to the original question before I went down this admittedly confusing road hehe :) [15:48] :-) [15:48] We aren't leaving itchy [15:49] <+Itchy> cool [15:49] <@TDavid> 12 more minutes to go, we are talking about how to determine NOT equal [15:50] <@TDavid> so if we want to make sure spaceman_ is NOT eating a fudge brownie? [15:50] <@TDavid> how do we go about doing it? [15:50] what does the code look like? [15:51] *** spaceman_ (spaceman_1@64.228.106.Ya18=) quit (QUIT: User exited) [15:51] <+Itchy> if spaceman=fugde brownie eq chcoclate chip type deal? [15:52] <+Itchy> i'm not a fast typer [15:52] but we want to see if he's NOT eating a fudge brownie... (i.e. NOT equal) [15:52] so it's similar.... [15:52] <+Itchy> eq =en then? [15:52] ne [15:53] <+Itchy> ne right hehe [15:53] :-) [15:54] <+Itchy> so if spaceman = fugde bronie en 'chocolate chip' [15:55] <+Itchy> makes him have a chocolate chip one right? [15:55] No... pretend that we already know that we're talking about spaceman and we have to test his $cookie now. [15:56] <+Itchy> if $cookie=fudge bronie en 'chocolate chip' [15:57] we want to know if $cookie is not equal to fudge brownie. If it isn't, then give him a fudge brownie. [15:58] <+Itchy> if $cookie != fudge brownie en 'fudge brownie [15:58] != is for numbers. :-) [15:59] first, let's test and see if $cookie is not equal to fudge brownie... that would look something like if ( ... ) [15:59] <+Itchy> != change to en and en change tp eq [16:00] Like this: if ($cookie ne 'fudge brownie') [16:00] this is your test to see if he's not eating a fudge brownie. [16:00] <+Itchy> pk [16:00] <+Itchy> ok [16:00] now, how do we give him one? [16:01] <+Itchy> ($cookie='fudge brownie') [16:01] there are 3 problems with that... you are very close though... [16:01] what are they? [16:02] <+Itchy> elsif ($cookie =' fudge brownie) [16:02] You don't need the elsif. :-) [16:02] nor an else. [16:02] <+Itchy> missing ; [16:02] <+Itchy> after bracket [16:02] perfect. [16:03] <+Itchy> does the ' need to be a "? [16:03] so we have now ($cookie = 'fudge brownie';) Still 2 problems.. (actually, they are 1) [16:03] an if statement looks like this: if ( ... ) { ... } [16:03] <+Itchy> wrong brackets [16:03] Yup! [16:03] *** MadamZ (java@208.8.133.OM576=) quit (QUIT: User exited) [16:04] so what does the final code look like? [16:05] <+Itchy> if ($cookie ne 'fudge brownie') {$cookie = 'fudge brownie';} [16:05] that's it! [16:05] <+Itchy> cool [16:05] <+Itchy> I'm learning [16:05] Yup! :-) [16:05] Good deal! [16:05] <+Itchy> a little one on one hehe [16:05] :-) [16:06] Here ends the chat. :-) [16:06] We'll pick up the rest of it on friday. [16:06] If in the mean time, you have any questions, PLEASE post them on the board. [16:06] <+Itchy> ok my mom just pulled it too see you friday :-) and thanks [16:06] You are welcome! [16:07] *** Itchy (itchmaster@24.70.215.1O46=) quit (QUIT: User exited) [16:07] *** FurBall sets mode -o TDavid [16:07] *** FurBall sets mode -o FurBall Session Close: Tue Feb 27 16:07:53 2001