Category "perl"

Perl: Multidimentional arrays and "experimental push" error

I'm a junior perl programmer and have very little experience with multidimentional arrays. I'm not even sure it is the proper data structure for this project. I

How to open a filehandle with an existing variable in perl?

In my Perl script, I would like to process lines from either STDIN or a given file, if specified, as common with Linux/UNIX command line utilities. To this end,

Handle multiple arguments to a Perl subroutine [closed]

As i have read ,"There’s another problem with this subroutine.This subroutine works properly only if called with exactly two Excess

IPC::Run - Detection of premature child exit and closed pipes

I would like to use IPC::Run to communicate with child via child's STDIN, STDOUT and STDERR (start, pump, finish). It seems to work. I would like to know how

Test two boolean values with AND operator in Perl

I want to test two boolean values in Perl. In case both are 0 do x, in case not do y. For example: $var1 = 0; false in Perl $var2 = 0; false in Perl if($var1==0

How to read HASH(0x1fcb970) using perl?

I'm really lost with this, how can I read this response form an API HASH(0x1fcb970) using perl. my @info= $connection->fetchrow(); When I try to print the d

Counting dictionary elements from Perl to Python

Looking for a best way to translate this piece of code from Perl to Python: my @arr = (); # [ 0 , 1 , 2 , 3 ] push @arr ,[$time,$host,$stat

Print the missing number in a unique sequential list with an arbitrary starting range or starting from 1

This question is similar to How can I find the missing integers in a unique and sequential list (one per line) in a unix terminal?. The difference being is that

Parsing HTML on the command line; How to capture text in <strong></strong>?

I'm trying to grab data from HTML output that looks like this: <strong>Target1NoSpaces</strong><span class="creator"> .... <strong>Targ

How can I format a number to 2 decimal places in Perl?

What is best way to format a number to 2 decimal places in Perl? For example: 10 -> 10.00 10.1 -> 10.10 10.11 -> 10.11 10.111 -> 10.11

Assignment of subroutine references in Perl script

I'm learning Perl from Intermediate Perl by Randal Schwartz. Can somebody explain the assignment of the variables $callback and $getter in the following code?

Dancer: deal with multiple requests simultaneously

Here's my situation: I'm developing a web application using Dancer framework, and I would like to insert some data to the database on the server side from the b

Absolute fastest way to recursively delete all files and folders in a given path. Linux

I am looking for the absolute fastest method of performing unlink and rmdir commands on a path containing millions of files and thousands of folders. I have fo

How to install Parallel::ForkManager in Perl?

I am tiring to run multiple jobs in parallel by using perl script which use Parallel:ForkManager. #!/usr/bin/perl -w use Parallel::ForkManager; my @make_obj

Perl: JSON::XS Is it possible to force boolean decoding as 1/0?

Package JSON::XS uses JSON::XS::Boolean objects to represent true/false. Is it possible to force decoding true/false json values as 1/0 Perl numbers? #!/usr/bi

How to check the presence of the internet connection in Perl?

I have a simple script that verifies periodically (once every few seconds) if there is internet connectivity from that server. To be clear, it's not about to ch

Is there a perl module equivalent to python's optparse.OptionParser? [closed]

I have a new script that I need to write in perl, to leverage our perl codebase (no, I can't convert it, not yet anyway). Our coding standards

using histogram to determine colored object presence?

I'm trying to determine if portion of the picture contains red-white striped object (liftramp). If it is present, it looks like this: , and when not like this:

Perl splitting on multiple occurrence of the same pattern

I wrote the following Perl script to split on multiple occurrences of the same pattern. The pattern is: (some text) This is what I've tried: foreach my $line

How to find maximum and minimum value in an array of integers in Perl?

I have an array with values 33, 32, 8, 100. How can I find the maximum and minimum value in this array? Do I need to include any special libraries?