Archive for the 'Perl' Category

Pacifickid.com nearly complete

Saturday, November 17th, 2007

Pacific Kid Tot

Ok, I think I’ve nearly got the design complete for my personal site, Pacifickid.com. I hope to have the layout done this weekend and start slicing/dicin it up into CSS/html. I’ve also been working on my own site framework in Perl for this. Got some interesting classes for dbi handling, can’t wait to share.

Ciao


Pass the PHP please…

Friday, December 22nd, 2006

Interesting article. Sigh.. I wait patiently for Perl 6. In the end I predict it’ll be Python and Perl.

Squash those bugs!

Friday, December 15th, 2006

Perl has gained the reputation, rightfully, as a hacker’s language, which has both negative and positive connotations. The community of Perl programmers often pride themselves as artists in the many ways they represent the counter culture of software development. There appears to be a general ignorance of the powerful tools available with Perl, especially among new comers to the community. I hope in the weeks to come to unveil the power behind the Perl Debugger. Be prepared, it’s going to be an amazing journey.

Pedantic Perl

Wednesday, December 13th, 2006

I came across this article on Perl.com, probably one of the best articles to describe Big “O” Notation in very simpleton terms. Of course those astute in algorithmic design know this encompasses all areas of computer science, just a good refresher to optimize any program one has wrote in whatever language.

Obfuscated Perl

Monday, December 4th, 2006
s;;5776?12321=10609$d=9409:12100$xx;;s;(d*);push @_,$1;eg;
map{print chr(sqrt($_))."n"} @_;

Guess what it prints:
L
o
g
a
n
Well... I'm proud of it.  PerlMonks have shortened it.


Goals before end of the year

Tuesday, November 21st, 2006

Mt Ashland Bunny Hill1. Submit workable Gen Pix to CPAN. (More info to come.)
2. Finalize my domain manager.
3. Walk or run a mile every single day until Jan 1st .
4. Take a picture everyday.

Seems easy enough. Lets see how self-disciplined I am.

The beginning there was nothing…

Friday, August 25th, 2006

Until I got bored and decided to write my own picture engine. Right now it just displays random images for the front page of my new picture gallery. With a little Ajax magic and CSS 2.0 fun we should have a kickin picture party.

Perl Oopssss :)

#! /usr/local/bin/perl -w
use strict;
my $picture = new Picture();
print $picture->randomPicture;

package Picture;

sub new {
my $class = shift;
my $self = {
dir => ‘./slovakia’,
reg_exp => ‘.*THUMB.JPG’,
site_domain => ‘http://www.loganandamy.com’,
site_dir => ‘/slovakia’,
@_
};
bless $self, $class;
}

sub giveMePicture{
my $self = shift;
return “siteDomain.$self->siteDir.”/”.$self->randomPicture.”\”>”;
}

sub randomPicture{
my $self = shift;
if (ref(@_)){
$self->{rand_pic} = shift;
}else{
$self->{rand_pic} = ${$self->openDir}[int(rand(scalar(@{$self->openDir})))];
}
return $self->{rand_pic};
}

sub openDir{
my $self = shift;
my $altdir = shift;
if (ref($altdir)){
$self->dirCriteria($altdir);
}
my $reg_exp = $self->fileCriteria;
my $dir = $self->dirCriteria;
opendir DIR, $dir || die “unable to open dir:$!”;
@{$self->{dir_files}} = grep {/$reg_exp/ && -f “$dir/$_” } readdir(DIR);
closedir DIR;
return $self->{dir_files};
}

sub siteDir{
my $self = shift;
shift @_ ? $self->{site_dir} = shift : $self->{site_dir};
}

sub siteDomain{
my $self = shift;
shift @_ ? $self->{site_domain} = shift : $self->{site_domain};
}

sub fileCriteria{
my $self = shift;
shift @_ ? $self->{reg_exp} = shift : $self->{reg_exp};

}

sub dirCriteria{
my $self = shift;
shift @_ ? $self->{dir} = shift : $self->{dir};
}

Floating Point Mystery(not really)

Tuesday, July 25th, 2006

I’m currently slugging my way through “Mastering Algorithms with Perl”, which is an excellent read for any lover of Perl, and I stumbled across some interesting factos. Take the following example:

#—-Example Begin—#
#!/usr/bin/perl

$answer = 2.4/0.2;

print $answer,”\n”;
print int($answer);

#—-Example End—#

Executing the above script will print the following:

12
11

Line one is what we expected, because 2.4 divided by 0.2 is 12, and 12 is technically the integer of 12. But wait a minute, there’s something wrong with line 2. So what devil is going on here? News to me, but apparently, with floating points, and this is with most programming languages, the floating point has a binary representation. What is really happening is the binary representation is being divided, which when converted back is less than 12. The int function in perl always rounds towards 0, hence 11.

More information in regard to the confusing world of floating points and computers, click here.