Perl and MQSeries for the faint of heart

Today I managed to finally get Perl to put and get messages to MQ Series. It's something that I've been wanting to do for quite some time, but didn't have the time or even MQ knowledge to do so.

This post is intended for those who, like me, aren't MQSeries gurus and can't make much of the documentation of the MQSeries module in CPAN. I hope it serves you well. Continue reading...

Perl Crash Course: Pragmas, Perl Modules, and CPAN

I always like to say that 90% of Perl is its modules. Back in 2000 when I was working as a junior Perl programmer I was asked to write a web application that, among other things, could send contact messages through email. Unfortunately, I never had anyone to really teach me the Path of Perl - I only relied on Learning Perl by Randall Schwartz, and whatever I could find on the net. I had a really hard time with that application, mainly because I didn't know about Perl modules, MySQL and SQL language. Had I been familiar with at least the Perl modules part, I wouldn't have had to spend 8 days and nights in the office (including my birthday). I didn't even know how to use strict; at the time! Keep reading if use strict; makes no sense to you.

Being the extensible and flexible language that it is, Perl provides us with some safeguards and helpers to assist in avoiding what happened to me (I wish I knew that back then). The first of which I'll talk about is Pragmas.
Continue reading...

New looks for usestrict

Folks,

I decided to change the looks of my blog. I'm using Atahualpa theme which is simply amazing. There are over 200 customization options which allow you to do practically anything you want.

If you are wondering about the logo, it is one of Pablo Picasso's drawings. I chose it because of its simplicity, which is in my opinion one of Perl's faces (I try not to get on its bad side - K.I.S.S.).

I hope you enjoy it.

Vinny.

Ajax Eye Candy: Create “Wait” icons on the fly

This is by far the coolest and handiest website I've come across in a very long time. Get your very own Wait icons for Ajax implementations on the fly.

http://www.ajaxload.info

It's not mine, and I don't know the author... but click an ad there if you like it. The guy deserves it.

Perl Crash Course: Basic I/O

author: Valeria Paixão
revision: André Batosti
enhancement/translation: Vinny Alves

Note from UseStrict: Some of the examples in this tutorial were borrowed from Randall Schwartz's Learning Perl. It's a book that EVERY beginner Perl programmer should have. If you don't have a hardcopy, please consider getting one. You can find it here: Learning Perl, 5th Edition

 

In this article, you will learn how to use basic I/O in Perl, learn about @ARGV, and become familiar with string formatting using printf.

STDIN

<STDIN> tells Perl to read from the standard input - usually the keyboard.

while (defined($_ = <STDIN>)) {
	print "I saw $_";  # echoes whatever is typed onto the screen.
                                # Quit with ^D or ^Z (depending on your system)
}

foreach (<STDIN>) {
        print "I saw $_"; # almost the same as above
}

The difference between the while and foreach loops above is that while executes its statements at every hit of the return key, while foreach slurps into memory all the input until eof (^D on Unixes) and only then executes its instructions.

It is important to note this difference if you don't want to crash your machine. If your input comes from a webserver with a 400MB log file, you're better off processing each line individually than slurping it all into memory.
Continue reading...

Perl Crash Course: File and Directory Tests and Manipulation

by André Batosti
revision: Vinny alves


Opening Files

To read or write files in Perl, you need to open a filehandle. Filehandles in Perl are yet another kind of identifier.
They act as convenient references (handles, if you will) between your program and the operating system about a particular file. They contain information about how the file was opened and how far along you are in reading (or writing) the file. They also contain user-definable attributes about how the file is to be read or written.

To open a new file on system you need to create the filehandle for this file using the command open

open(filehandle, pathname);

The filehandle is the identifier that will describe the file and the pathname - the full path of the file you trying to open. Typically it is represented by a constant, but when working with complex programs, it is best to use a scalar variable in order to safely pass it from one subroutine or method to another.

Continue reading...

Perl Crash Course: Control Structures

by André Batosti
revision: Fernando Giorgetti and Vinny Alves

Control Structures are used to control the flow of a program. We are going to see programs that can iterate (loop) or make decisions (conditionals) based on the state of variables.

More interesting possibilities arise when we introduce control structures and looping. Perl supports lots of different kinds of control structures which tend to be like those in C, but are very similar to Pascal, too.
Continue reading...

Perl Crash Course: Basic Regular Expressions

by Nadia Kozievich
revision: Vinny Alves


Introduction

A regular expression (or regex) is a simple, rather mindless way of matching a series of symbols to a pattern you have in mind. The origins of regular expressions lie in automata theory and formal language theory, both of which are part of theoretical computer science.

In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. Regular expressions (abbreviated as regex or regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.

Regular expressions are used by many text editors, utilities, and programming languages to search and manipulate text based on patterns. For example, Perl, Ruby and Tcl have a powerful regular expression engine built directly into their syntax. Several utilities provided by Unix distributions including the editor ed and the filter grep where the first to popularize the concept of regular expressions.
Continue reading...

Perl Crash Course: Subroutines

Introduction

Subroutines are user-created functions that execute a block of code at any given place in your program. It is a best practice, however, to aggregate them all either at the beginning or the end the main program.

Subroutine declarations initiate with the key word "sub" . Conventionally, subroutine names are all lowercase characters

sub NAME (PROTOTYPE) BLOCK

print_hello; # subroutine can be executed/called before the actual block is created

sub print_hello {
      print "Hello world\n";
}

When we called print_hello we told Perl that we wanted the piece of code named print_hello to be executed. The result is a "Hello World" showing up on our screen. The only benefit we have from that snippet in its current form is that we won't have to copy/paste the print statement all over our script if we want to repeat it. All we need to do is call print_hello;
Continue reading...

Terreno à Venda / Land for sale

Português

Pessoal, estamos querendo vender nosso terreno em Itabirito/MG. O lugar é em um condomínio fechado, lindo e pertinho de BH. Mais informações no nosso hotsite: http://www.idiomasviaskype.com/itabirito

English

Folks, if you are in Brazil or thinking about moving over, we are selling a piece of land in the town of Itabirito near Belo Horizonte, the capital city of Minas Gerais state. It's a beautiful place. For more information, send me an email or ping me here on my blog.