Found 448 Articles for Programming Scripts

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

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

2K+ 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

3K+ 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

2K+ 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

5K+ 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

7K+ 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

Fuzzy Logic and Probability: The Confusing Terms

AmitDiwan
Updated on 14-Oct-2022 11:58:23

1K+ Views

In this article, you will understand the difference between fuzzy logic and probability. Fuzzy logic It is a many-valued logic where the truth value of variables may be a real number between 0 and 1, including 0 and 1. Everything is associated with a degree. It is based on natural language processing. It can be integrated with programming. It is best suited for approximation. It is generally used by quantitative analysts. It helps understand the concept of vagueness. It captures the meaning of partial truth. The degree of membership is in a set. It is used in air conditioners, ... Read More

Voca: The Ultimate Javascript library for String Manipulation

Mukul Latiyan
Updated on 11-Oct-2022 14:24:39

339 Views

Voca is a JavaScript library that is used for manipulating strings. In this tutorial, we will take multiple examples to show how you can use the different functions available in Voca. Features of Voca Before we see all the examples, let's highlight some features that Voca brings to the table − It provides a multitude of functions that can be used to manipulate, query, escape, format strings. It also provides a detailed and searchable documentation. It supports a wide range of environments like Node, js, Safari 7+, Chrome, Firefox etc. It doesn't require any dependencies How to Install ... Read More

Logging HTTP Requests and Errors using Morgan.js

Mukul Latiyan
Updated on 11-Oct-2022 14:18:24

2K+ Views

Morgan is a middleware that is available for Node.js which is used when we want to log HTTP requests. It is mainly used in Express projects. Morgan helps us simplify the logging work of HTTP requests that come and sent from an application in a single statement. In normal situations, developers often write all the logging code by hand and then end up logging what to store, how to save, and where everything is saved. It helps in gathering logs from your server and also prepares them for reading. It also has many predetermined defaults built-in to help the developers. ... Read More

What are top JavaScript animation libraries?

Kalyan Mishra
Updated on 11-Oct-2022 08:57:37

966 Views

Have you ever thought of creating complex animations using CSS, well in JavaScript also there are some libraries which helps in creating animation and tasks that CSS also cannot perform. AS CSS animations are limited in functionality on the other hand JavaScript libraries are fast and reliable So, this article we will be learning about some of the best JavaScript animation libraries using which you can create animations in JavaScript. Let’ see some of the JavaScript animation libraries. Anime.js Anime.js is known as lightweight animation library which s use to animate HTML, JavaScript objects, CSS selectors and DOM attributes, arrays ... Read More

Difference between location.host and location.hostname in JavaScript

Imran Alam
Updated on 10-Oct-2022 11:57:01

3K+ Views

JavaScript's Location object provides access to the current URL's components. One can think of this object as a read-only window into the current location. There are two properties of the Location object that are often confused: host and hostname. Location.host The host property returns the hostname, port number, and protocol of the current URL. For example, if the current URL is "http://example.com:8080/path/to/page.html", the value of host would be "example.com:8080". Advantages of using location.host There are also a few advantages to using location.host over location.hostname. First, it is more specific. If you need the port number or protocol, you can be ... Read More

Advertisements