1. Why Perl?

Perl is a great, usable language, that is worth learning. This website should convince you: small, but practical code examples are provided, whether or not with comprehensive annotations. To mention some Pros:

  • It’s stable and actively developed
  • It’s very, very fast.
  • It’s a language that is easily to understand (indeed, easy for ‘VisualNeo Win’ developers)
  • It has a massive documentation, tutorials, books etc.
  • It has more than 200.000 modules to invoke and to extend your Perl script (1). So why reinvent the wheel? In addition, most of the modules provide example code!
  • It has a large community. And e.g. on reddit.com and stackoverflow.com many questions and answers on Perl programming problems can be found.
  • The sympathetic concept: TIMTOWTDI (2), meaning “there is more then one way to do it”.
  • Regular expressions are Perl’s core business. This means that text processing is a very powerful feature.
  • In Perl, large amounts of data can be managed in complex structures in memory, similar to a database (3).
At the time of writing these snippets, I used Perl 5.36 - 5.38 on ArcoLinux (arcolinux.com).


Footnotes
(1) You may ask if these modules are of good quality. I can’t guarantee, but if often more than one developer is involved in creating the module (controlled by a community), I’ve no doubt…
(2) Which solution do you want? :-)

$concat = $a.$b;
$concat = "$a$b";
$concat = join ", $a, $b;
$concat = sprintf("%s%s",$a,$b);
$concat =~ s/.*/$a$b/s;
(3) Example:

$rec -> {"id"} -> {"$tag1"} -> [$nr1] -> {"$tag2"} -> [$nr2]
With the 'store' and 'retrieve' function multiple data structures can be saved and loaded at once very quickly.

store([$rec, \%Even, \%Tag1, \%Tag2, \%Tags, \%Stat], "Filename");
and

$arr = retrieve("Filename");
%{$rec} = %{$arr -> [0]};
%Even = %{$arr -> [1]};
%Tag1 = %{$arr -> [2]};
%Tag2 = %{$arr -> [3]};
%Tags = %{$arr -> [4]};
%Stat = %{$arr -> [5]};
In this example, apart from the main structure $rec, the additional 5 hashes %Even, %Tag1, %Tag2, %Tags, and %Stat are also saved in the file. However, you may have fewer or more hashes.