Minecraft style terrain using perlin noise

Ok,

I am not new to scripting, but I am new to for loops and perlin noise. So far, I have written a piece of code that generates something that looks like a city block:

#pragma strict

var width : int = 20;
var length : int = 20;
var height : float = 20;

var spaceBetweenCubesGround : float = 2;
var spaceBetweenCubesAir : float = 1;

var cube : GameObject;

function Start ()
{
GenerateCube();
}

function GenerateCube()
{
    for (var z = 0; z < length; z = z + spaceBetweenCubesGround) {
        for (var x = 0; x < width; x = x + spaceBetweenCubesGround) {
        	var c : int = Random.Range(0, height + 1);
        	for (var y = 0; y < c; y = y + spaceBetweenCubesAir) {
	            Instantiate(cube, Vector3 (x, y, z), Quaternion.identity);        	
        	}
        }
    }
}

This generates something like this:

I know if I make ‘spaceBetweenCubesGround’ variable 1, then there are no spaces between the towers. (But never mind about that)

I am trying to generate an island made out of cubes. I could do that with the code I am showing above, but that wont look natural. I have now come to the conclusion that the easiest way to do this would be to generate an image (Using perlin noise) and from there, use that as a ‘heightmap’ for the cubes. However, I do not know how to do this, coding-wise.

I have the perlin noise script from the Procedural Examples pack, but I do not know how to work with it. Help?

A suggestion, as long as you go about it the right way.

You can actually view the source code of minecraft (decompile it):
http://www.minecraftwiki.net/wiki/Minecraft_Coder_Pack

Now as long as you remain in the terms of mojang’s license agreement, you could use it as a way to learn how they generate their maps.

I’m not an authority on the license agreement, but I will say, do NOT directly copy the code, or the process of the code. Just use it as a way to learn how such things are done.