Get the App
SLTechnology News&Howtos  ›  Development  › 

How to avoid common Perl errors

Shulou Source: shulou.com Published: 2022-06-02 07:56:53 10月18日 Update

This article mainly introduces how to avoid common Perl errors, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Five common Perl errors

I've been making things with Perl+mdbm+spread recently.

Php has been used for a long time, python and ruby have been used, but Perl has never touched the classic scripting language, and now it is holding a textbook like a primary school student. I found that Perl is really much more difficult. Other things don't make me make mistakes so often.

1. Output * A common Perl error is to output content to a file. The standard syntax is:

PrintSTDERR "thisisanapple."

It's usually written as

PrintSTDERR, "thisisanapple."

Always put an extra comma. To be honest, I seldom make mistakes repeatedly, but I just can't remember this place.

two。 The second common Perl error is that arrows referenced by Hash are often omitted.

It should have been written

Print$hash- > {$key}

Is often written as

Print$hash {$key}

3. The third common Perl error is string comparison:

Php has been used for a long time, always using two equal signs to compare strings. This is wrong. The correct way to write is

If ($vareq "hello") {

Print "world"

}

It is often written as:

If ($var== "hello") {

Print "world"

}

This can lead to logical errors that are difficult to detect.

4. The fourth common Perl error: if statements without parentheses (all bad by php)

The correct way to write it is:

If ($var)

{

Print "yes"

}

Is often written as

If ($var)

Print "yes"

5. There is another Perl error: if it is not brought from php, most people will not make it: omitting semicolons.

Thank you for reading this article carefully. I hope the article "how to avoid Common Perl errors" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Errors common articles writing characters strings frequent honest three things two values interests content semicolons at the same time places primary schools pupils that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Tech Info Shulou Information Microsoft Apple