DEV Community

kycodee
kycodee

Posted on • Updated on

Perl Language Explained

What is Perl?

Practical Extraction and Reporting Language, also known as Perl, is a high-level programming language. It was developed in 1987 by a developer named Larry Wall. Initially, Perl was created as a unix scripting langauge that makes it easier to process reports. Recently, it has been performing it's original tasks, but it has been revised multiple times to perform on a higher level. I'll discuss with you a few of the main features that has kept Perl relevant throughout the years. One of them is Perl's ability to create CGI scripts that can perform some of the most difficult tasks seen in modern-day software development. Another thing we'll be discussing today is Perl's syntax and how it differs from the syntax of other languages such as Javascript.

Scripting

Perl is most commonly used for it's text manipulation and scripting capabilities. Common Gateway Interface, also known as, CGI has been the thing keeping perl alive recently. CGI is used to exchange information between web servers and custom scripts. It has the ability to create scripts that access databases, create webpages, and even generate graphics. Much of this scripting working is done in a shell, since Perl is a unix-based program. The generation of these scripts is a breeze when using perl since it has APIs that manipulate almost any text so that XML, HTML, and other markup languages can be used.

Syntax

If you've ever programmed in any other language, learning Perl should not be too hard of a task. For instance, coming from a Javascript background, Perl has been very easy to learn. Perl, just like Javascript, has variables, loops, blocks, and comments. The difference between JS comments and Perl comments is that JS uses '//' to comment things out and Perl uses '#'. Also, variables in Perl are declared with a '$' symbol in front of them. For example, if you wanted to store a value in a variable called dog, you would have to name the variable $dog instead of dog.

$dog = 'roscoe'; #correct syntax
dog = 'roscoe';  #incorrect syntax
Enter fullscreen mode Exit fullscreen mode

Downsides

There are a few downsides to consider when dealing with the Perl language. One major con of Perl is it's slow initial execution time. Perl is a language that has to be compiled before use, so this causes a delay. Perl also is not as lightweight opposed to other languages. Lots of CPU and ram is used every time you execute something within Perl. Another complaint that Perl developers usually have is it's untidyness. Since Perl is so forgiving and lacks strictness, there are many ways to achieve the same result, making code unreadable.

Conclusion

If you are interested in creating CGI scripts or just making extremely powerful code, I'd suggest giving Perl a go. Considering all of the pros and cons we discussed about the language, it still seems to be a very viable option. Perl hasn't been very popular in recent years, because of newer options but it definitely isn't going anywhere soon. If becoming a Perl developer is something you're interested in but are on the fence about it, remember that Perl is often considered the 'swiss-army knife' of programming.

Sources

Perl.org
Simplilearn Perl
TechTarget: Perl

Top comments (0)