Saturday, January 31, 2009

Twitter and tag cloud

I have been playing with the blog template recently, while figuring out how to move on with the RankSearch project.
You will notice two visible changes to the right-hand side of this blog:
  1. A link to my twitter profile
  2. Added a tag cloud in replacement of the list
Some other changes that are not visible:
  1. Added my blog's feed automatically to twitter and identi.ca thanks to twitterfeed.com
  2. Played with my feed's settings to redirect all post feed traffic to FeedBurner
The twitter button was taken from here among a huge selection of templates.

The tag cloud was set in place thanks to frivolous motion's excellent post. It doesnt add a title by default but the solution was in the comment section. Just make sure to select the right line containing

and add just after it:



The "includable" line in question is the one right after the html tag for your tag cloud widget:
Make sure you have checked the "Expand Widget Templates" box in the Edit HTML page.

French expression of the day:
"C'est mon petit doigt qui me l'a dit": a little bird told me (litt. My little finger told me)

Next posts:
  • Our first Perl program - Part III: Launch a HTTP request
  • How to install and use Google Analytics on your Blogger blog
  • Our first Perl program - Part IV: Read results from a HTML page
  • Perl help resources
  • Our first Perl program - Part V: Result analysis
  • POD
  • Our first Perl program - Part VI: Add a GUI interface

Wednesday, January 28, 2009

CPAN, or how to get your project jump-started

CPAN
CPAN is not a TV channel about politics, nope.
It stands for Comprehensive Perl Archive Network.

It is a gold mine where you can dig amongst close to 15,000 Perl modules. No need to reinvent the wheel, you're very likely to find a module that suits your need in CPAN.
This archive is one of the strength of the Perl community. Most of the modules are open-source and you can scan through 20,000,000 lines of code. There is great material there for beginners to chew on!

The Strawberry Perl distribution includes a full tool chain to install Perl modules from CPAN (as you would do from Linux). This is the main difference with ActivePerl.
ActivePerl allows you to go through its PPM (Perl Packet Manager) system to install pre-compiled modules. You can also download CPAN source code and compile it yourself but you will have to deal with the dependencies yourself.

When installing a module from CPAN, you will automatically pull all dependencies on that module as well, making your install as easy as typing cpan at a DOS prompt.
This will open the cpan shell. Typing help will display all possible commands.
If you know the name of your module, just type install ModuleName and let the process run its course.

RankSearch
CPAN is the place where I'll start in order to investigate core functionalities for the RankSearch.pl script (for http requests and html parsing).
I posted on the Websearch Help forum to see if anybody could answer the question about RankSearch.pl violating Google's terms of service.

French expression of the day:
Deep snow in the Winter, tall grain in the Summer: "Janvier rigoureux, an très heureux" and "Vaut mieux voir un chien enragé que soleil en janvier." (litt. Better see an enraged dog than sun in January)

Next posts:
  • Our first Perl program - Part III: Launch a HTTP request
  • How to install Google Analytics on your Blogger blog
  • Our first Perl program - Part IV: Read results from a HTML page
  • Perl help resources
  • Our first Perl program - Part V: Result analysis
  • POD
  • Our first Perl program - Part VI: Add a GUI interface

Monday, January 26, 2009

RankSearch - The end already?

A friend at work informed me that the script that I have in mind for RankSearch might violate Google's Terms of Service.
I did some research and it looks like he's right. From Google's ToS:

Automated queries

Google's Terms of Service do not allow the sending of automated queries of any sort to our system without express permission in advance from Google. Sending automated queries absorbs resources and includes using any software (such as WebPosition Gold™) to send automated queries to Google to determine how a website or webpage ranks in Google search results for various queries.

What's your take on that? If RankSearch is implemented as a sequence of http queries, will it violate the ToS? This could get DamienLearnsPerl banned (I would get my life back!).
On the other hand, the amount of queries would be really low...
I looked for an email address to contact Google to ask the question but couldn't find any. Will look again tomorrow.

French expression of the day
"Chat échaudé craint l'eau froide": once bitten, twice shy (litterally: scalded cat fears cold water)

Next posts:
  • More about CPAN
  • Our first Perl program - Part III: Launch a HTTP request
  • How to install Google Analytics on your Blogger blog
  • Our first Perl program - Part IV: Read results from a HTML page
  • Perl help resources
  • Our first Perl program - Part V: Result analysis
  • POD
  • Our first Perl program - Part VI: Add a GUI interface

Sunday, January 25, 2009

RankSearch - Part II: parsing the Perl command line

RankSearch: The design
The design of our little script is laid out in the comment header from last post:

1. Get the parameters from the user
  • In a first version, ensure that all parameters are filled
  • Later, we can provide a default value for the search engine (Google)
  • Or even display all the results for a list of supported search engines
2. Launch an http request with the parameters given by the user
  • Spawn a process able to communicate back to our script
  • It will probably be in the form of "http:\\$engine-blabla-search_criteria-moreblabla"
  • Need to investigate different urls for different search engines
3. Parse and display the results transmitted by the http process
  • Search for the target URL
  • Keep track of rank count
  • Launch new http request with updated page number if target not found
  • Display result to user
Today, I'll strike off the first item of the list. Time to get interactive!
In order to ease the handling of user input, I discovered that Perl includes the Getopt::Long module by default. The link on CPAN will show you all possible uses of the module.
One must be careful not to omit the "\" character before the variable name (like I did at first).
We'll only use string (character chain) inputs:
use Getopt::Long;
GetOptions (" engine="s" => \$SearchEngine);
This will store in $SearchEngine the parameter entered from the following perl command line:
perl "$(FULL_CURRENT_PATH)" --engine www.google.com --target damienlearnsperl.blogspot.com --keyword "learn perl"
or
perl "$(FULL_CURRENT_PATH)" -engine www.google.com -target damienlearnsperl.blogspot.com -keyword "learn perl"
or even
perl "$(FULL_CURRENT_PATH)" -e www.google.com -t damienlearnsperl.blogspot.com -k "learn perl"
(provided you only have one entry in Getoptions starting with "e")

Here's the script:
#!/usr/bin/perl -w
# --------------------------------------------------
# File   : RankSearch.pl
# Author : DLP
# Date   : January 24th 2009
# Object : Looks in a search engine what is the rank
#          for a given website and a given keyword
# Input  : - Search engine URL, eg. "www.google.com"
#          - URL of website to monitor
#          - Search expression to investigate
# Bugs   : None
# To do  : - Launch http request
#          - Read html result
#          - Analyse result and display website rank
# --------------------------------------------------
use strict;
use Getopt::Long;   #Load module

# Global variable
my $PROG_NAME = "RankSearch";
my $VERSION   = "v0.0.1";
my $PROG_DATE = "January 24th 2009";

# --------------------------------------------------
# Main program
# --------------------------------------------------
# More global variables
my $SearchEngine = "";
my $TargetURL = "";
my $Keyword = "";

#Parse command line arguments
GetOptions ("engine=s"  => \$SearchEngine,  #string
    "target=s"  => \$TargetURL,
    "keyword=s" => \$Keyword);

# Check user input
if ($SearchEngine eq "" ||
$TargetURL eq "" || $Keyword eq "")
{
print "
You must enter a valid string for:
--engine  = search engine URL
--target  = the target of the search
--keyword = the search criteria
";
exit;
}

print "
$TargetURL is ranked nth on the $SearchEngine
search engine for the \"$Keyword\" criteria.";

__END__
Jan 24 2009 (0.0.1): first version of RankSearch
Jan 25 2009 (0.0.2): get params from command line

After getting the parameters, we check to see if anything was entered at all.
If $SearchEngine, $TargetURL or $Keyword are still empty chains (or undefined) then we print an error message and exit the program (the operator for a logical OR is "||" or.. "or"! I don't get the differences yet).

In Notepad++ you can modify the execute command line (via the F6 shortcut) to:
perl "$(FULL_CURRENT_PATH)" -e www.google.com --target damienlearnsperl.blogspot.com --keyword learn perl

This result will appear as:

Notepad++ execution console
Note that the criteria entered by the user was "learn perl" and it was displayed as "learn" by the script. We'll just have to make sure that double quotes (") are used when the string input has a blank space.

French expression of the day:
"Ce que femme veut, Dieu le veut": A woman's will is God's will
As you can see, God and strong-minded women are universal.

Next posts:
  • More about CPAN
  • Our first Perl program - Part III: Launch a HTTP request
  • How to install Google Analytics on your Blogger blog
  • Our first Perl program - Part IV: Read results from a HTML page
  • Perl help resources
  • Our first Perl program - Part V: Result analysis
  • POD
  • Our first Perl program - Part VI: Add a GUI interface

Saturday, January 24, 2009

Retrieve the search rank for your blog automatically

I was reading the latest article over at Pretty Your Blog yesterday and it gave me an idea for a first script. The FileInfo program that I wanted to present is already written and I may come back to it later. The RankSearch project that I have in mind will be written from the ground up so you'll be able to monitor the progress as I crawl towards completion. I hope you'll pitch in as well!

RankSearch: The need
Kelly wrote in Pretty Your Blog:
I ran another (unofficial) experiment; I did a google search for frugal blog. And the result? Almost Frugal was on the 13th page of search results.
It is very likely that Kelly clicked on the next link at the bottom of each Google page until she found her blog's reference (by the way, if you are interested in improving your blog, you may want to visit Pretty Your Blog often :).
What if we could write a Perl script that automatically returns the Google rank based for any URL on a given keyword? That's the idea behind RankSearch.pl

RankSearch: The specifications
The script will have to be as generic as possible and would take 3 input parameters:
- Search engine URL (eg: "www.google.com" or "www.yahoo.com")
- URL of the blog you want to check the ranking for (eg: "almostfrugal.com")
- The search criteria you are investigating (eg: "frugal blog")

The output result will be a simple message of the type:
almostfrugal.com is ranked 7th on the google search engine for the "frugal blog" criteria.

It will run on Windows and Linux environments
Do you see anything else to add?

And here is the template for it:
#!/usr/bin/perl -w
# ----------------------------------------
# File : RankSearch.pl
# Author : DLP
# Date : January 24th 2009
# Object : Looks in a search engine what is the rank
# for a given website and a given keyword
# Input : - Search engine URL, eg. "www.google.com"
# - URL of website to monitor
# - Search expression to investigate
# Bugs : None
# To do : - Read input and store in script variable
# - Launch http request
# - Read html result
# - Analyse result and display website rank
# ----------------------------------------
use strict;

my $PROG_NAME = "RankSearch";
my $VERSION = "v0.0.1";
my $PROG_DATE = "January 24th 2009";

print "$PROG_NAME $VERSION from $PROG_DATE.\n";

__END__
Jan 24 2009: first version of RankSearch

French word of the day:
"économe": frugal

New posts:
  • Our first Perl program - Part II: parsing the Perl command line
  • More about CPAN
  • Our first Perl program - Part III: Launch a HTTP request
  • How to install Google Analytics on your Blogger blog
  • Our first Perl program - Part IV: Read results from a HTML page
  • Perl help resources
  • Our first Perl program - Part V: Result analysis
  • Our first Perl program - Part VI: Add a GUI interface

Friday, January 23, 2009

Launch your Perl script from Notepad++

Today I am going to explain how you can be using Notepad++ to run Perl scripts.
It can be convenient to launch your program directly from the editor's environment to quickly check that it compiles.
Let's try and set up Notepad++ to launch the script from Wednesday's post.

In the Plugins menu, you will find the NppExec plugin.
Select Plugins>NppExec>Execute...
You can also use the convenient F6 shortcut.

Notepad++ interface to the execute command
Once the Execute... window is open, type in the following command:
perl "$(FULL_CURRENT_PATH)"$(FULL_CURRENT_PATH) is an internal Notepad++ variable that contains the full path of the file currently open in the editor.
There is a list of 10 such global variables here. We might come back to them later.
So, hitting F6 for our example is equivalent to typing the following line in a DOS shell:
perl C:\Perl\usr\skeleton2.pl

You can save this command line and give it a meaningful name ('perl' for example).
Of course, you can enter any command (or sequence of commands) that you would type at a DOS prompt:
perl -v
dir
...


The output result is visible on the Console window.Perl script execution on Notepad++ output console
You can get rid of the "Process..." lines by selecting Plugins>NppExec>No Internal Message
Also, if you want to repeat the previous command, you can just type Ctrl+F6.

If you know more Notepad++ tips, I'd love to hear from you!

A few words about the new skeleton:
The -w added at the end of the shebang line is the equivalent of use warnings;

$PROG_NAME, $VERSION and $PROG_DATE are called scalars. They are composed of a $ followed by a variable name. Scalars are used to represent a single element (in this case, they are all strings, because initialised as characters between double quotes).
The my function has to do with the scope of the variables. It is optional but I was told it is good practice to use in conjonction with the use strict command.
We'll see if we can figure out why later. If you have a clue, please drop a comment.

Finally, the last line makes use of the variables declared at the top of the script:
print "This is $PROG_NAME $VERSION from $PROG_DATE.\n";
Strings between double quotes (") are interpolated. This means that when the Perl interpreter sees $PROG_NAME between quotes, it will replace it by its current value.
If you replace the " by a single quote ('), then the output will become:
This is $PROG_NAME $VERSION from $PROG_DATE.\n

Come on, try it! All it takes are 2 key strokes and Ctrl+F6!
Finally, "\n" is understood as the next line character.

Today's French expression would not get approval from Larry Wall:
"La paresse est source de tous les vices": An idle person is the devil's cushion.
"Paresse" is the French word for lazyness. This is a quality for a developper according to Larry, because it pushes him/her to create scripts in order to automate his work and avoid repetitive tasks.

New posts:
  • Our first Perl program - Part II: parsing the Perl command line
  • More about CPAN
  • Our first Perl program - Part III: Add a GUI interface
  • How to install Google Analytics on your Blogger blog
  • First version of FileInfo script
  • Perl help resources

Wednesday, January 21, 2009

Perl syntax highlighting in Blogger

I did it! It took me a while but I managed to get Perl syntax highlighting for this Blogger blog!
Check out the end result:
#!/usr/bin/perl -w
# ----------------------------------------
# File : Skeleton.pl
# Author : DLP
# Date : January 18th 2009
# Object : Template for new script
# Known bugs : None
# To do : Nothing
# ----------------------------------------
my $PROG_NAME = "Skeleton";
my $VERSION = "v0.0.2";
my $PROG_DATE = "January 21st 2009";

print "This is $PROG_NAME $VERSION from $PROG_DATE.\n";

__END__
Jan 18 2009: first version of the Perl skeleton
Jan 21 2009: v0.0.2
- changed "used warnings" into -w on shebang line
- created global variables for program version info
Pretty neat, don't you think?
I tried for a long time to modify the blog's layout (in the Blogger menu, Customize->Layout->Edit Html) by manually inserting lines of code as described here ot there.
Both of these sites are using syntaxighlighter for different languages. It looked really good and I wanted it! Unfortunately, syntaxhighlighter does not support Perl (why?!!).
After much trial and post botching, I was getting frustrated. I would see a good result from Windows Internet Explorer but not from Firefox (problem also noticed by Soon Hui, see his blog).
I finally stumbled on Fazibear's post. He shared a Blogger widget that whould do all the dirty work for you. All you have to do is to install the widget from the Layout page. Then, when you have code to add to your post, you edit the Html and surround your code by:


your code
Simple and effective... except that Perl syntax would not get highlighted (see list of supported languages here).
Thankfully, there are always helpful souls on the web and Bear Den Designs's blog has posted the bit of javascript code that was missing from the syntax highlighter widget.
I just had to edit the Blogger Syntax Highliter widget and copy the extra code between the lines:

dp.sh.Highlighter();dp.sh.Brushes.JScript.Aliases=['js','jscript','javascript'];

dp.sh.Brushes.Ruby=function()
...

Et voilà!

French word of the day:
"Victoire!": Victory!

Next posts:
  • Perl development tools - Part II: setting up Notepad++
  • Our first Perl program - Part II: parsing the Perl command line
  • More about CPAN
  • Our first Perl program - Part III: Add a GUI interface
  • How to install Google Analytics on your Blogger blog
  • First version of FileInfo script

Monday, January 19, 2009

Syntax highlighting woes

I am having some trouble with the setup of my posts.
I want the perl scripts that I publish to use the same syntax highlighting that you get in Notepad++.
So I used the NppExport plugin of Notepad++ and exported to a .html document (tried to a .rtf file also).
I copied and pasted the html code from the created html file to the WYSIWYG editor of blogger but the text formating has disappeared and I end up with something like that:

#!/usr/bin/perl
use warnings;
print "This is not so easy";

Then I tried to copy the html code from the exported html file into the "Edit Html" tab of the editing window but it doesnt work any better.

I have googled syntaxhighlighter but it doesn't support the Perl syntax. Somebody was nice enough to create a Perl extension. So I'll be trying it out in the next few hours. I will try re-publishing yesterday's post so don't go thinking that your feed reader has gone crazy.
And sorry for the inconvenience, I'm learning here ;)

French word of the day:
"J'apprends": I am learning

Sunday, January 18, 2009

A Perl template - Part I: The Basics

The hardest thing when it comes to programming is to sit in front of a blank screen and wonder how to start coding.
Good programming practices tell you to design your application before you type the first line of code.
Some program methodologies (Extreme Programming for example) will have you create the tests before you work on your main project.

For now, I am just going to present the very basics of Perl. The goal of the next few posts will be to build a very simple script skeleton. This template will serve as a base for a new project (and eliminate the dreaded white screen).

Enough talking, here is our first Perl program:

Type the above line in Notepadd++ and save the file as skeleton.pl.
The .pl extension means that the file is a Perl script.
Then open a DOS shell (cmd.exe) and type

C:\Perl\usr>skeleton.pl
This is easy
C:\Perl\usr>

The .pl file is executed by the C:\strawberry\perl\bin interpreter (if its correct location is in your PATH environment variable. Check how to see that here).
The print command displays a line on the standard output which is the DOS shell on your computer screen by default.

This program would run on Windows only. For Linux machines, you have to tell the computer where to find the Perl interpreter. Because we want our scripts to run on any machine (portability), we'll rewrite our first example with a few additions:

The first line starts with what is called a she-bang: #!
On Unix systems, it tells the operating system what the type of the file is and where to find the interpreter.
use warnings;
This line tells the Perl interpreter to give warnings for bad practices.

All lines starting with a # are comments.

The semi-column (;) at the end of non-comment lines are used to separate Perl statements. This is why the last ; can be omitted (but it is better to keep it in case you add more lines to the bottom of your file later).

The __END__ token tells the Perl parser to consider this line as the end of the program. Anything you write after it will not be considered a part of the Perl program and ignored.
You can use this knowledge to add some documentation at the bottom of your file.

French expression of the day:
"C'est le premier pas qui compte": The first step is always the hardest.

Next posts:
  • Perl development tools - Part II: setting up Notepad++
  • Our first Perl program - Part II: parsing the Perl command line
  • More about CPAN
  • Our first Perl program - Part III: Add a GUI interface
  • How to install Google Analytics on your Blogger blog
  • First version of FileInfo script

Saturday, January 17, 2009

Install Strawberry Perl on your Windows computer

As I mentioned before, you have selected the Strawberry Perl distribution to be the environment of choice for this blog project. The nal tally is:
- 4 votes for ActivePerl
- 8 votes for Strawberry Perl
- 4 voters didn't care one way or the other.

You can download here version 5.10.0.3 of the Strawberry Perl distribution for Windows.

Strawberry Perl installer iconDouble-click on strawberry-perl-5.10.0.3.exe to start the install process.
On Vista, you will need to authorize the installation process.
The configuration is pretty straightforward. A "C:\strawberry" folder will be created.


If you selected to create an entry to the Windows program manager, you will find there:
On your computer, the files in the C:\strawberry directory are organized in that fashion:
  • \c
--> contains tools to build modules found on CPAN
  • \cpan
--> where your CPAN modules will be installed.
  • \licences
--> Gnu GPL (General Public License). This is the base of the open source philosophy. It basically says that software distributed under the GPL must include its source code. Any modification of the source and redistribution is allowed but the modified source must also be made public.
  • \perl
--> \perl\bin contains the perl.exe interpreter.
--> \perl\lib contains the perl core source files and all the base perl modules.
  • \win32
--> has the four web links cited above.

In order to see if the interpreter is installed correctly, open a command shell: Windows Start Menu -> type cmd.exe in the Search box for Vista (Run box for XP)
Check that c:\strawberry\perl\bin has been added at the end of your path by typing:
path
at the DOS prompt.

Finally, type
perl -v
and make sure you get a message similar to the one below (click on image to zoom).

perl -v output
Congratulations! Perl is now installed on your machine.

French expression of the day:
"Tout vient à point à qui sait attendre": All things come to those who wait.

Next posts:
  • Hello World program
  • More about CPAN
  • Perl development tools - Part II: setting up your environment
  • How to install Google Analytics on your Blogger blog
  • First version of FileInfo script

Thursday, January 15, 2009

Perl development tools - Part I: the text editor

Like the smith with a hammer, a forge and an anvil, the would-be programmer needs tools to perform his trade. Thankfully, only a few of them are required to program in Perl (none of which is an anvil).

The most basic tool is an advanced text editor. You could write Perl scripts using Notepad but there are free alternatives that make programming much more comfortable. To reuse our smithy analogy, the better the tools, the quickest and sturdiest your work will be.

There are scores of free text editors and you are welcome to choose any of your liking.
Personally, I will be using Notepad++:

Notepad++ logo- It supports Perl syntax highlighting
- It has regular expression capabilities
- It is an open source project.
- You can install plugins to add more functionalities

Download the editor's installation file from here. You can also get the zip version. The latest available version at the time of this post is Notepad++ 5.1.4.

We'll see later how to fine-tune the configuration of the editor. Notepad++ is one of the more popular choices and is used for a wide range of programming languages.

French expression of the day:
"C'est en forgeant qu'on devient forgeron": Practice makes perfect (litterally: It is by forging that one becomes a smith)

Next posts:
  • More about the Strawberry Perl distribution
  • No follow links
  • How to install the Strawberry Perl distribution and set up your Windows development's environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • First version of FileInfo script

Tuesday, January 13, 2009

Get a grant from the Perl Foundation!

The Perl Foundation (an organization dedicated to advance the Perl language) is offering grants ranging from $500 to $3000. Those will be bestowed upon the best projects that will benefit the Perl community. You must submit your project before January 31.
An example of project that was awarded such a grant in the past is Strawberry Perl.
Another landmark in Strawberry Perl 's list of achievements is that it came up first in our survey about the Win32 Perl distribution of choice for DLP.
There will be more on Strawberry Perl in another post but I'd be interested to hear from you why you selected it over ActivePerl.

French word of the day
"une fraise": a strawberry

Next posts:
  • More about the Strawberry Perl distribution
  • No follow links
  • How to install the Strawberry Perl distribution and set up your Windows development's environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • First version of FileInfo script

Sunday, January 11, 2009

Blogroll: one word of explanation

Real quick explanation about the blogroll section:
I read somewhere that being referenced by other websites increases the page ranking of the linked blog.
So there it is, I have added the most underrated blogs (in my eyes) that deserve recognition (not that they're likely to get much publicity from DLP). Here they are, in alphabetical order:
I also made a deal with mochaquest.com for a link exchange:
- They put my blog's URL in their blogroll and I add theirs on mine.
- We become members of each other's Facebook blog network.
I think this practice is common amongst bloggers who want their traffic to pick up.
Have you heard about it? Do you do the same on your blog?

French word of the day:
"un blog": a blog (short for web log)

Next posts:
  • Poll results on Win32 Perl distribution
  • How to get the Perl distribution and set up your Windows environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • First version of FileInfo script

Saturday, January 10, 2009

Introducing Larry Wall

Larry WallLarry Wall is the founder of the Perl language.
I won't write anything about his biography in this post, you can find it all here (and here for the French version). I just want to point out that Larry's academic education in linguistics shows up a lot in how the Perl language is structured.
To the left is a picture of the man, taken by Randal Schwartz, another key Perl figure.

The preface of the Programming Perl book states that "Perl is designed to make the easy jobs easy, without making the hard jobs impossible". Perl is very good at:
  • handling numbers and text
  • manipulating files and directories, computers and networks
  • running external programs and parsing the output results.
Programming is the most rewarding thing to do when you own a computer. This is what computers are meant to do: run useful or fun programs to help or amuse you.
Perl is a great language to learn programming because you can start writing useful scripts right away with the minimum syntax knowledge.
The Perl's motto is "There Is More than One Way To Do It", also known as TIMTOWTDI (pronounce Tim-tow-dee). As we start programming, we'll be using "Baby Pearl" as Larry puts it, but that's ok. We'll pretty up the scripts as we grow in Perl.

French word of the day:
"un rubis": a ruby
Incidentally, Ruby is the solution of the question asked in the previous French word of the day section.

Next posts:
  • What's that Blogroll thing that you added?
  • How to get the xxx Perl distribution and set it up in your Windows environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • First version of FileInfo script

Thursday, January 8, 2009

"Perl on Windows" background reading

To help with your assignment (i.e. decide whether to use ActivePerl, Strawberry Perl or another Perl distribution for Windows), I highly recommend reading the Win32 Perl Wiki.

Among the interesting reads, the list of all Win32 Perl distributions shows an exhaustive table of all the distributions that ever existed for Windows.

A Perl distribution is a set of software and tools revolving around the Perl core. The latest official version of Perl is 5.10.0. A Win32 Perl distribution is a version of Perl tools + core that can run on a Windows operating system.

French words of the day:
"une perle": a pearl
Note that another programming language (inspired by Perl) takes it name from a gemstone. Can you guess what it is? The answer in the next post...

Next posts:
  • What's that Blogroll thing that you added?
  • How to get the xxx Perl distribution and set it up in your Windows environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • First version of FileInfo script

Tuesday, January 6, 2009

Google Love

On Sunday night, a search in Google for "Damien Learns Perl" returned this blog in the results!
This means that I am in! "Google he knows me, and he knows I'm right" as would sing my friend Phil.
A search for "learns Perl" returned this blog in second position behind... Soumya Learns Perl!
Her site (I assume she's a girl) is a wiki and it looks like it is not updated any more.
Anyway, it looks totally different from what I want to do.

I also stumbled Damien Learns Perl (DLP). I am an avid Stumbler and I have discovered plenty of interesting website by using the Stumble bar. You too can give DLP the thumbs up! If you don't know Stumble Upon, discover it at your own risk: it is highly addictive...

A search on Yahoo did not return anything so I addedd my blog to the Yahoo site explorer.

Summary of my actions so far to make DLP known:
- Submitted DLP's URL to Google and it took less than 3 days to get listed.
- Added DLP's URL to one directory
- Added DLP to the Stumble Upon's search by writing a review and adding as many tags as I could: (computers, programming, open-source, perl, blogging)
- Submitted DLP's URL to Yahoo (on Sunday night)
- Added AdSense ads on the blog: so far it has earned a little bit over $3! I'll keep you posted on the numbers.
- Advertised DLP on Facebook to get more readers in my blog's network: I am up to 12 readers as of Tuesday night, thank you all! Because I have over 11, I have "unlocked" the blog feed feature.

French proverb of the day:
"Tout vient à point à qui sait attendre": All good things come to him who waits

Next posts:
  • What's that Blogroll thing that you added?
  • How to get Perl and set up your Windows environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • How to publicize your blog - Part II
  • First version of FileInfo script

Sunday, January 4, 2009

A few assumptions

Alright, the fun is about to start.
Sorry for delaying the actual Perl programming part of this blog and thank you for your patience. I just wanted to make sure that I would actually have an audience before starting head first. Now that Google analytics is installed (more in a later post), I'll be able to monitor how many people come and pay me a visit! If you don't want to miss any post, please consider subscribing to this blog (links to the right). For Firefox users, I recommend the Sage feed reader (I like it).

I am monitoring the comments by email so even if you drop a line or two on a previous post, I will be seeing it (and possibly replying to it in time).

I am going to make a few assumptions about my readership. Please correct me if I'm wrong:
  1. Some of you have no experience in programming, or very little.
  2. You like to learn by getting your hands dirty: no lengthy and theoretical lecture but practice on subjects that interest you.
  3. You think adding Perl in your toolbox can help you with your computer skills. Improve your blog, parse web pages and add a line to your resume while having fun!
  4. You know how to use a computer. You can open a directory to check for files and use the basic features of your operating system.

  5. Side note for Linux users:
    Perl is present in most standard Linux distributions. In order to check the Perl version that you are using, open a terminal and type:
    perl -v
    Typing
    which perl
    will show in which directory the Perl interpreter is located.

    From now on, I will also assume that:
  6. You are using a Windows operating system (Vista, XP, NT or 98). I am personally using Vista. Google analytics tells me that most of you use Windows, except for the one person who surfs on his iPhone. I know who you are!
Perl is a very portable language and I will do my best to write scripts that run on both Windows and Linux (and possibly Mac).

The first exercize is to choose and download a Perl distribution for Windows. We have two main options:
I let you research the web for the distribution that you prefer. Both are free.
I already have my opinion on the question but I would like your take on the subject.
I will open a second poll in the right-hand side of this post for you, or you can just leave a comment. I will go with the popular vote.

French word of the day:
"une découverte": a discovery

Next posts:
  • What's that Blogroll thing that you added?
  • How to get Perl and set up your Windows environment?
  • How to install Google Analytics on your Blogger blog
  • Hello World program
  • How to publicize your blog - Part II
  • First version of FileInfo script

BREAKING NEWS

LifeHacker brings the news of a web hosting deal from DreamHost for under $11 for 2 years (a $215 value). I looked it up and it seems like a really good deal but it expires today (January 4th).
For bloggers who already have a domain name, this could be interesting. I am not ready to commit to a domain name for Damien Learns Perl just yet so I'll pass this one (and I will regret it later?).
Here is the link:

New Year's deal: get 24 months of hosting domain for under $11

French expression of the day
"une bonne affaire": a bargain (litterally: a good deal)

Saturday, January 3, 2009

How to publicize your blog - Part I

Today, I noticed that typing "Damien learns Perl" in the Google search box does not return this website as a result...

This is not surprising as this blog is shiny out of the box and has not yet been crawled by the Google bots yet (the way I understand it, Google sends its little spiders crawling all over the web to discover new pages to add to its database).
After a little research (and by Google's own admission), I discovered that adding your URL to Google could take a very long time before they add your site in their database.
I also found some people who think they know tricks to accelerate the process:
The name of this game is SEO, short for "Search Engine Optimization".
It is the set of techniques used to make your blog or website appear at the top of the search engine lists.

Feeling adventurous, I took the following steps for DLP (Damien Learns Perl):

1. I inserted ads from Google's AdSense program. Several reasons for that:
  • Adding AdSense boxes actually increases the chances of getting listed by Google (at least, that's what tech-recipes.com says, see link above)
  • Some ads might be relevant to you as AdSense scans the contents of each post to target its ads to the appropriate audience. I will do my best to keep it light.
  • When someone clicks on an add, I earn a few cents (haven't figured out the math yet).
  • By looking at the AdSense stats, I can have a rough idea of the site's traffic. I know this is not ideal and I will try to figure out a better solution later. Suggestions? Also, I know I will not see you guys who are using Firefox with AdBlock Plus (little tricksters!).
2. I submitted http://damienlearnsperl.blogspot.com/ to the Google search engine (because it might just be enough)

3. I also registered the URL on http://www.freesubmitwebsiteurl.com/

I'll keep you posted for the results.

Next steps:
4. Register on other directories
5. Register URL on other search engines (Yahoo, AltaVista, AskJeeves, etc.)
6. Add an entry on Wikipedia?

French sentence of the day:
"Quand commence-t'on à apprendre Perl?": When do we start learning about Perl?

Next posts:
  • How to get Perl and set up your environment (Windows and Linux)?
  • Hello World program
  • How to publicize your blog - Part II
  • First version of FileInfo script

Friday, January 2, 2009

Change of plans

Don't worry, I am still planning to learn all the Perl I can safely ingest.
My change of plans concerns our first Perl project.
I realized that counting C code lines might not be everybody's idea of having fun.
Although the line counting script had potential for starting slowly and building up on features, I decided to start on a much more interesting subject:
  • Our first Perl script will be parsing pictures files taken from a digital camera.
  • It will give the option of renaming files according to the metadata located in jpeg files or it will just display the file information without touching the file name.
  • Information read from the file could be: date when picture was taken and resolution (width x height) for starters.
I've put up a poll at the top of the blog for you to approve/disapprove this move. This will also allow me to check if anybody is reading this blog besides me ;)
I am open to any suggestion if you have a better idea.

You'll notice that I've listed the posts to come at the bottom of each message. This is more a guideline than an exact prediction of the future. In my next post, I'll try to talk about how I plan to make this blog known all over the web (how hard can it be?).

French word of the day:
"une désillusion": a delusion

Next posts:
  • Learning how to publicize your blog
  • How to get Perl and set up your environment (Windows and Linux)?
  • Hello World program
  • Search Engine Optimization for your blog
  • First version of FileInfo script

Thursday, January 1, 2009

A little bit about me (and you?)

First, Happy New Year 2009!

My name is Damien and I live in France.
I share a small appartment at the feet of the Alps with 3 beautiful girls: my daughters and their mother (who, by a funny coincidence, also happens to be my wife).

I have been an embedded system engineer since 2000 and have worked for 2 companies:
- an American firm specialized in payment systems in Atlanta, GA then Philadelphia, PA
- a European microelectronics company in Grenoble, France

I have mainly programmed in C on embedded systems (8-bit 8051 for smart card applications and 32-bit SH4 for video decoder system-on-chips).
My career is moving towards testing/quality assurance. In order to automate testing tools, I have undertaken the learning of the Perl scripting language.
I have had three days of Perl beginner's class and have purchased the "Programming Perl" O'Reilly book by Lary Wall (father of Perl), Tom Christiansen and Jon Orwant. It is also referred to as the "Camel book" because of the front cover (although it is really a dromedary, which goes to show that Perl programmers are not natural science buffs). Here it is in all its splendor:

The Perl Camel bookAnd here are a few reviews:
Check it out if you have a chance. This is the ultimate reference book on Perl (co-author Tom Christiansen is in charge of the Perl documentation). The "Learning Perl" book may be better suited to learning the language but I don't have it at home. We'll just have to dig through the Camel book and look for help on the web.

How about your background? What is your goal for learning Perl? Are you starting/writing a blog also?

French words of the day:
- "un chameau": a camel (two lumps)
- "un dromadaire": a dromedary (one lump)

Next posts:
  • Learning how to run a blog
  • How to get Perl and set up your environment (Windows and Linux)?
  • Hello World program
  • Search Engine Optimization for your blog