Perl snippets that would help in solving quick and easy problems
How to dump variable in perl Have you guys ever needed to dump variables in perl and see its exact contents? I had and was really tricky. The print function is alright for printing scalar variables, but when you try to print a hash and maybe with multiple levels you start to have headaches trying
Read and write and delete a file in perl In this article I’m going to try and show you some operation examples to read, write and delete a file in perl using a few methods, like the saying goes … There’s more ways to skin a cat … So yes, more ways to work on a file.
Perl split string example Perl split string function is one of the few perl functions used in string manipulation. It is similar to explode in php which will create for you an array with the pieces from the specified string. In this post snipped, you will see a quick example of how this can be
Find string in array in perl There are cases in your projects where you will most likely want to search an array for a specific element or string. There is no function like how it is in PHP for example that could do this automatically, but there is one core function that can be used
How to create a while loop in perl This post snipped is to show you how to create a while loop using perl, obviously this is possible in almost every programming language. Scenario You have to make some checks or print something until a certain limit or count. For eg. you want to print a
Creating arrays and hashes in perl I’m sure for those users looking for dynamically storing their information they will most likely rely at some point on arrays. Here are some quick snippets on how to create arrays and associative arrays in perl (hashes). Creating an array in perl Arrays are preceded by the symbol “@”,
How to strip spaces out of a string in perl You have a variable string that may have blank spaces at the end of the string or at the start of the string and you need to remove these spaces so that you can make use properly of the value of that variable. Scenario
//You want to strip spaces from the left side and right side of the bellow string and obtain "username"
$val_string= ' username ';