Server Side Programming Articles - Page 401 of 2650

How to compare two arrays for equality in Perl?

Mukul Latiyan
Updated on 26-Dec-2022 16:44:26

3K+ Views

In Perl, there are two ways to check if two arrays are equal. We can compare two arrays in Perl with the help of "Storable freeze" function or by creating our own custom function. In this tutorial, we will explore both these approaches with the help of examples. Example 1 Let's first explore the "Storable freeze" code and understand how it works. Consider the code shown below. use Storable qw/freeze/; use strict; $Storable::canonical = 1; my @countriesOne = ('India', 'China', 'Russia', 'USA', 'Germany'); my @countriesTwo = ('India', 'China', 'Russia', 'USA', 'Germany'); my @countriesThree = ... Read More

How to check if a variable has a numeric value in Perl?

Mukul Latiyan
Updated on 26-Dec-2022 16:42:44

4K+ Views

Suppose we get a variable at runtime in Perl and we want to check if the value that it contains is numeric or not, then we can use the two approaches shown in this tutorial. We will use two simple examples to demonstrate how it works. Example  The most basic approach is to use the length and do keywords and then ignore the warnings. Consider the code shown below for the same. $x = 100; if (length(do { no warnings "numeric"; $x & "" })){ print "x is numeric"; } else { print ... Read More

How to check if a Perl hash already contains a key?

Mukul Latiyan
Updated on 26-Dec-2022 16:40:11

5K+ Views

Let's consider a scenario where we would want to know if a Perl hash already contains a key or not. To do so in Perl, we can use the exists() function. In this tutorial, we will explore the exists function with the help of two examples. The exists() Function in Perl In Perl, the exists() function checks whether a particular element exists or not in an array or a hash. If the requested element appears in the input array or hash, this function returns "1", else it returns "0". Example 1 Consider the code shown below. In this example, we ... Read More

How to check if a file exists in Perl?

Mukul Latiyan
Updated on 14-Mar-2023 18:05:09

4K+ Views

In this tutorial, we will take a couple of examples and demonstrate how you can if a file exists or not, with the help of Perl. Let's suppose we have a simple text file called "sample.txt" with the following data − This is a sample txt file that contains some content inside it. TutorialsPoint is simply amazing! We will use a Perl code to check whether this file exists or not. Example 1 The most basic approach to check whether a file exists or not is to use the "-e" flag and then pass the name of the file. ... Read More

How to check if a Perl array contains a particular value?

Mukul Latiyan
Updated on 26-Dec-2022 16:28:21

9K+ Views

In Perl, we can check whether an array contains a particular value or not with the help of the "grep" keyword. The grep function in Perl is used to filter the input supplied in the function as a parameter out of the list of items. Similar to Linux, it uses the given input to find the matching value. The grep() Method "grep" is a built-in function in Perl, we can pass our regular expression inside this function. It will check the input for matching values and return a list based on whether the condition is true or false. Syntax As ... Read More

How to break out of a loop in Perl?

Mukul Latiyan
Updated on 26-Dec-2022 16:23:22

10K+ Views

In most programming languages, we can use the "break" keyword to break out of any type of loop. In Perl too, we have the "break" keyword available, but the keyword that is used the most to break out of a loop is the "last" keyword. The "last" Statement in Perl The "last" statement is used in Perl loops to exit a loop immediately; it is the equivalent of the "break" statement in C/C++ and Java. In practice, you often use the "last" statement to exit a loop if one of the conditions is met, for example, you find an ... Read More

Why is Python such a common beginner's language?

Vikram Chiluka
Updated on 26-Dec-2022 13:55:05

348 Views

In this article, we will learn Why is Python such a common beginner's language. The following are the various reasons for it. Why is Python a better first language for beginners? There are other excellent programming languages available, but Python is one of the finest for beginners. It has a simple syntax and straightforward(clear) instructions, making it simple to read and write. Python is also intended for beginners, so you won't have to spend time reading complicated manuals or tutorials. Python is popular due to its ease of learning and teaching. Another reason why people like Python is that it ... Read More

What are the best Python 2.7 modules for data mining?

Vikram Chiluka
Updated on 26-Dec-2022 13:49:20

320 Views

In this article, we will learn the best Python 2.7 modules for data mining. The following are some of the best Python 2.7 modules for data mining − NLTK Beautiful Soup Matplotlib mrjob NumPy pybrain mlpy Scrapy NLTK Natural Language Processing (NLP) is the process of using software or a machine to manipulate or understand text or speech. Humans interact and understand each other's points of view and then respond appropriately. This interaction, understanding, and response are made by a machine rather than a human in NLP. NLTK(Natural Language Toolkit) is a standard Python library that includes ... Read More

What are some Underrated Python Libraries?

Vikram Chiluka
Updated on 26-Dec-2022 12:52:41

682 Views

In this article, we will learn some underrated Python libraries. The following is a list of some of the underrated libraries in Python − Emmett Jam.py Missingo Emot Shogun Blaze Bamboolib Swifter Caffe Myia Featuretools Altair AutoViz Emmett The Emmett web framework is the first package that is severely underrated and underestimated. The Emmett web framework is flexible and may be used for many various applications in web development. Another advantage is that the Emmett web framework is relatively simple to utilize. It uses Flask−like syntax, making it relatively simple to learn if you are already familiar with ... Read More

What are some things one may dislike about Python?

Vikram Chiluka
Updated on 26-Dec-2022 12:51:06

244 Views

In this article, we will look at some of the things that most people dislike about Python. Using Indentation Instead of Curly Braces Many people complain that Python fully relies on indentation to build code blocks. In Python, as you may know, indentation is not optional. The complaints vary, but they frequently include one or more of the following. It is Difficult to Tell Where a Function Ends That is true when writing large Python functions. However, it would be advantageous if you avoided writing large functions altogether. This is true for any language, not just Python. A function should ... Read More

Advertisements