March 01, 2005

Cravin' Salt and Programming

My first (well second, but that one doesn't count) Perl program! Of course, I can paste the source code now... hopefully eventually it'll be so long I will have to tell you about it. #!/usr/bin/perl -w use strict; # To test for a palindrome 2005 02 28 #-Input--------------------------------------- my $word1 = $ARGV[0]; if (! $word1) { print "\n"; print "Palindrome 2005\n"; print "Please enter a word to check: "; $word1 = ; chomp ($word1); } else { print "\n"; print "Processing on $word1\n"; } #-Format Inputs------------------------------- my @array_word1 = split (//, $word1); my $array_word1_length = scalar @array_word1; #-Test---------------------------------------- my $palindrome = 1; my $i; my $x = $array_word1_length - 1; for($i = 0; $i <= ($x - $i); $i++) { if ($array_word1[$i] ne $array_word1[($x - $i)]) { $palindrome = 0; last; } } #-Result-------------------------------------- my $not; if ($palindrome == 1) { $not = ""; } else { $not = " not"; } print "\n"; print "The word $word1 is$not a palindrome!\n"; print "\n"; #=End========================================= Haha its a simple dalindrome test but still, its more than I have ever programmed before. And on top of it.... it works! Its in Perl. Man, I am craving fatty foods and salt like no other. Its sad. This morning I had 4 egg whites and hash browns (no grease or salt mind you). Oh and the lack of ketchup! So for a snack I get chicken breast and a plum, for lunch a rice, beggie an d chicken mix. It all sounds good but its all flavourless! It needs gobs of salt and grease! Its driving me insane! Well at least in the long run I will hopefully be in better shape. I will be healthy for sure. Oh and I am getting my 300 GB hard drive hopefully tomorrow or the day after.

0 Comments:

Post a Comment

<< Home