Gabor Szabo Perl Trainer

Global symbol requires explicit package name

Global symbol requires explicit package name is a common, and IMHO very misleading error message of Perl. At least for beginners.

The quick translation is "You need to declare the variable using my."

The simplest example


  use strict;
  use warnings;

  $x = 42;

And the error is

See the full article


Use of uninitialized value

A lot of people consider the errors and warnings of Perl to be great. Usually that's true but in my experience, they can be very confusing to people who are not yet familiar with Perl. I'll describe some of them.

Quick explanation


  Use of uninitialized value $x in say at perl_warning_1.pl line 6.

This means the variable $x has no value (its value is undef). Either it never got a value or something assigned an undef value to it.

See the full article


How to get the Perl Weekly every day?

No, no! I am not wrapping time yet.

I am just trying to smooth the production of the Weekly Perl newsletter.

So I have started to post news items as I read them.

If you would like to get updates more frequently than the weekly newsletter then this might be for you.

See the full article


Understanding Regular Expressions - part 1

Using regular expressions provides us with enormous power, but reading and understanding complex regular expressions is not an easy task. I noticed, it feels much easier to write a regular expression than to read it.

This is probably true regardless of the host language but in Perl we tend to use regexes much more than in other languages.

See the full article


How to read a CSV file using Perl?

Reading and processing text files is one of the common tasks done by Perl. For example often you encounter a CSV file (where CSV stand for Comma-separated values) and you need to extract some information from there. Here is an example:

See the full article