This blog no longer exists.
You will be redirected to something cool.

Wednesday, August 31, 2011

Move Ahead in Perl or Try Something New?

I'm just about halfway done with my Perl course and it feels really good. I'm not sure if I'm going to go on to a more difficult Perl course or to go on to another language.

There two sides to this coin. If I go on to the cert for open source programming, this course is it for Perl. I would then move on to an intro course for Python, a course on the Unix file system (which would be fun), an intro course on PHP, and the finish off with a database programming course (which I think would be a blast.)

If I stay with Perl and move on to more advanced Perl-y things, I think I would learn more about computer science, in general, but it would be more focused on one particular language versus "Survey of Computer Science" so to speak.

Tonight's section was difficult for me, but I got everything down. My big problem was that, while my code worked, it was generating warnings.

My code was as follows:

if ($var eq undef)
{
  do a thing
}
else
{
  do something
}

To fix it, I did the following:
if ($var)
{
  do something
}
else
{
  do a thing
}

Chip learning some
Ruby with me
I don't think the solution I came up with was in the chapter I'd just read, but it was marked correct. I am trying to solve problems with the information they present versus going off on my own and using "outside" information to solve things.

It's been really hard because I've been wanting to write methods, loops, etc, pretty much since I started out in the course, but haven't gotten there yet. I'm trying to keep it relevant to exactly what is taught so I don't get ahead of myself and learn bad habits.

I am going to go hog wild on some Ruby stuff, though. I read a little more of Well-Grounded Rubyist, but had to stop as I wanted to try something out that I was learning... and I'm have a big problem getting Ruby installed. (I recently formatted.)

1 comments:

If you wanted to check that a variable merely has a value (so, is not undefined), you can use the defined() operator:

if( defined( $var ) ) { ... }

Even if the value is literally '0' (or the empty string), you'll still execute that block.

The other way has perils, because a value or 0 or the empty string won't pass this test, and the block won't run. Those are defined values, but Perl just considers them to be false (by definition):

if( $var ) { ... }

I like to "ask questions" in my conditions to make sure I'm doing the right thing. Asking "Are you defined" show what I expect out of the conditional. :)

Good luck,