Newest 'perl' Questions - Stack Overflow

Questions tagged [perl]

Perl is a procedural, high-level, general-purpose, dynamic programming language, known for its native support of regular expressions and string parsing capabilities. Please use this tag for questions about Perl in general. For things related to the new (but related) language "Perl 6", please use the perl6 tag. For Perl-style regular expressions in other languages, use the regex tag, or, if they are based on the PCRE library, the pcre tag.

0
votes
2answers
20 views

How to get values in a non-constant position?

String contains: #EXT-X-STREAM-INF:BANDWIDTH=1439890,RESOLUTION=640x480,CODECS="avc1.42001f,mp4a.40.2" The order of key-value pairs is not constant. Examples: #EXT-X-STREAM-INF:BANDWIDTH=1439890,...
0
votes
0answers
15 views

How to run perl debugger at runtime with PERLDB_OPTS?

I have following perl script #!/usr/bin/env perl sub bar { foo() } sub foo { } sub hello { bar(); } hello(); Which produces following output $ PERLDB_OPTS="NonStop frame=1" perl -d 1.pl > /dev/...
-1
votes
1answer
27 views

JSON decode failed

Following is the code snippet where I am observing error: "malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at" Error observed is ...
0
votes
0answers
13 views

Where I can find opj2opengl.pl file for Mac and use commands to convert .obj to .h?

I have created .obj file which is a cube object with texture. Since two days, I am searching on how to convert that .obj file to .h file and use in my iOS project which is created using Vuforia iOS ...
1
vote
0answers
18 views

Fonts rendering differently in graphics magick

I am using graphics magick with PerlMagick interface to create images. There are currently 2 systems which are generating the images. System 1 is using the graphics magick version: 1.3.29 System 2 is ...
0
votes
0answers
21 views

Perl Net::IMAP::Client can't connect to imap-server on raspi (stretch light)

Script to connect email account using Net::IMAP::Client works on windows, but doesn't connect on raspi. I developed the script on windows and it works fine. When I try to run it on my raspi (...
0
votes
0answers
27 views

I am facing an issue with one of the perl module DB_File.pm

The DB_File.pm is throwing the following error: AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' Argument "/home/epri..." isn't numeric in subroutine entry at /usr/lib64/perl5/vendor_perl/...
-2
votes
1answer
24 views

How to read a excel file using perl?

How to read excel file in Perl CGI? my $book = ReadData('$lBASEPATH/macro/$gProj/TCO_Excel_Export/TCO_Data_201931316467.xlsx'); say 'A1: ' . $book->[1]{A1}; print $book;
1
vote
0answers
52 views

Perl code crashes after upgrading from rhel6 to rhel8

I have been migrating from a rhel6 server with Perl 5.10 to a server with rhel8 and perl 5.24 and 5.26. Everything works fine except one Perl program crashes executing a warn statement. Using the ...
1
vote
1answer
23 views

Which http headers to suppress “This document is no longer available.” on browser back button?

A perl script creates a download page with this URL http://server/cgi-bin/oursite/script.pl?action=checkme&username=myname with headers set by: my $q = new CGI; ... print $q->header(-expires ...
-1
votes
0answers
18 views

How to set file access operator for all(user, group, other) in perl script [duplicate]

I have tried so many method like sysopen() or umatch but that doesn't work plzz help me out
1
vote
1answer
52 views

What is a performant way to split long lines when only a subset of fields is desired

The details of my query follow: I have a very large TSV (Tab Sep. Value) file (where large > 30 GB). I want to extract certain lines from this file that don't end with an empty last field. Since this ...
1
vote
1answer
16 views

How to display a statement at a specfic row and column using Term::Cap module in perl

I writing a code which will display a statement at 2 nd row and 10th column using Term::Cap module in perl . I have tried the below code #!/apps/perl/5.8.9/bin/perl # use strict; use warnings; ...
0
votes
1answer
39 views

Adding an array of floats produces weird sums adding forward vs. backward

I'm adding (summing) and array of floats in perl, and I was trying to speed it up. When I tried, I started getting weird results. #!/usr/bin/perl my $total = 0; my $sum = 0; # Compute $sum (adds ...
0
votes
1answer
28 views

Problem converting a text file into binary file using perl

I would like to convert some data in binary using Perl. The data needs to be output in 8 bits binary. The original data comes in this format: 137.0000 136.0000 133.0000 136.0000 10.0000 134.0000 0....
2
votes
1answer
25 views

Syntax error using a filehandle stored in a hash value

I am trying, with a one-liner, to write lines read from an input source to different files according to the contents of a field of the line itself. My method was to use a hash to store the ...
9
votes
3answers
68 views

Perl Regex Command Line Issue

I'm trying to use a negative lookahead in perl in command line: echo 1.41.1 | perl -pe "s/(?![0-9]+\.[0-9]+\.)[0-9]$/2/g" to get an incremented version that looks like this: 1.41.2 but its just ...
1
vote
1answer
40 views

execute failed: Incorrect string value: '\xD6sterl…' with mariadb and perl DBD

I'm a novice perl programmer trying to use DBI to write a buffer of text that contains an email with umlauts and other non-ASCII characters to a joomla database and having a problem. DBD::mysql::st ...
0
votes
1answer
43 views

Perl HTTP request skips proxy server and connects to target directly

I'm trying to write a perl script to pull data from a web address through a Squid proxy server. I have Squid server running on CentOS7, listening on port 3128 and authenticating with /usr/lib64/squid/...
1
vote
2answers
37 views

Perl: Milliseconds to Date+Time

I am trying to convert a variable in Perl that contains milliseconds to date/time format. The catch is that variable came from mainframe TIMESTAMP that can not be converted by Unix/Linux because the ...
-2
votes
1answer
40 views

Convert perl to python3

I am trying to re-create a perl code into python3 code. I do not have enough python expertise to do it. Thanks in advance. I tried (in python) to split() and other thing but I am getting no where. ...
-1
votes
1answer
31 views

sort cannot read files in bash script [duplicate]

I'm passing file names to a bash script from a Perl script. When I echo the file names they look correct, however, sort cannot read the files and displays '$'\r' at the end of the file name. #!/bin/...
-4
votes
1answer
42 views

Filtering files with the given range of inputin perl [on hold]

The perl script which takes an input i.e name of the file, I need to find all the files that matches with that pattern. Example: given input as 2019052300 2019052323 (YYYYMMDDHH) Here, I need to ...
-3
votes
0answers
34 views

LWP Proxy Fails

Creating a kind and slow bot that would be wonderful if it would cooperate with using proxies. But nothing that offers a proxy is being handled like one. I could post all sorts of code used in ...
0
votes
1answer
35 views

How to install package modules(manually) in activeperl [duplicate]

I'm working on an example in perl in oops concept.I'm unable to install the perl package modules. This file is saved with student.pm package Student; require Exporter; use vars qw(@ISA @EXPORT);...
3
votes
3answers
71 views

Is it possible to run only particular sub under debugger?

I want to print stacktrace only of particular subroutine. Is it possible ? Script is running under perl without -d option. Simple example: #!/usr/bin/env perl foo(); sub foo { print "Hello ...
1
vote
2answers
49 views

Is there any way to check whether a file is an empty file using PERL program?

I am looking a small script which will tell me whether a file is an empty file or not , but i am unable to display this. I have used the below code : opendir DIR,$directory ; while (my $dir =readdir ...
1
vote
2answers
51 views

Perl Date::Manip detects timezone wrong for EST and EDT

I have the server where system timezone is EST It was set with # timedatectl set-timezone EST # timedatectl Local time: Tue 2019-06-18 03:29:42 EST Universal time: Tue 2019-06-18 08:29:42 UTC ...
0
votes
0answers
21 views

Adding line chart with Perl where data set is zero does not draw a line

I am working on a script which creates an excel file and line charts based on the given values. However, the situation can occure, where a whole data set is 0. When this is the case, excel does not ...
0
votes
1answer
35 views

Perl qx() command not working as expected

I have a perl script as below, where I want to access a network path on a remote windows machine from a linux machine using rsh. $cmd = "rsh -l $username $host \"pushd \\\\network\\path\\to\\the\\...
1
vote
6answers
63 views

Perl string replace not working with $1 and $2

Search and replace is not working when I use $1 and $2 defined earlier. It works when I store it in a new variable. Does not work as intended. perl -e' my $name = "start middle end"; my $...
0
votes
2answers
34 views

Perl replace string contents within quotes

I have a large xml file that I am reading line by line. <Role elemId="id35" island_id="0" role_name="Design" value="True"/> <Role elemId="id34" island_id="0" role_name="Lead" value="False"/&...
0
votes
1answer
34 views

Unable to retrieve data from stash with key that contains a single quote

The database contains company names that have single quotes within the name. When the user selects a company, I need to retrieve from a hash with the key=CompanyName. Problem I'm having is not being ...
1
vote
2answers
44 views

Calling a Perl hash function

How do you call a function from a hash value? %hash = { "1" => \&some_function } ; # this function has one parameter sub some_function { my $arg = $_[0]; return $arg; } $hash{"1"}->($...
0
votes
1answer
35 views

How do I run build files through Strawberry Perl command line?

I am using Strawberry Perl and the command line. I need to know how to install packages like MinGW. I've downloaded MinGW from Github and I need to run the following command- ./build --mode=gcc-4.8.1 ...
-2
votes
0answers
65 views

Print in rows for selected greps in sequence of lines

I have file like below, with few hundreds of lines: $ cat file1 TAP 1.0 .1.2.3.0 .0.3.2.1.1 .1.2.3.1 .1.3.2.1.1 .1.2.3.2 .2.3.2.1.1 .1.2.3.3 .3.3.2.1.1 .1.2.3.4 .4.3.2.1.1 .1.2.3.5 .5.3.2.1.1 TAP 1.0 ...
-2
votes
1answer
27 views

Perl - truncate where values overlap and concatenate

I am new to the Perl language and am trying to convert some data from a MYSQL database. I'm working on pulling addresses from two different tables, and my goal is to concatenate a "complete" address. ...
0
votes
1answer
38 views

How to print rows information from two dimensional array in Perl?

I have the following two dimensional array (file.txt): Code Element Repetitions AL Train 23 BM Car 30 CN Bike 44 From an input (Code) given by the user, I want to ...
0
votes
1answer
42 views

Input argument is a file or an either content to Perl

I wrote a Perl script to convert from TEX format to JSON format. Calling in the batch file: perl -w C:\test\support.pl TestingSample.tex This is working fine now. Perl script having two types of ...
-2
votes
0answers
46 views

Can you analysis Phising scripts?

My webserver has hacked, there's unknown phising code is run on crontab */12 * * * * perl /var/tmp/lwDleou >/dev/null 2>&1 It changes index.php ,header some unknown urls, it makes my ...
-1
votes
1answer
36 views

Get error result when search match for only one time

I wanted to search a string that matched exact times in another string, while I met some problem. use strict; use warnings; my $test="abc1234abc5678abcdef910"; my $cut_seq="abc"; print $test,"\tone ...
-1
votes
1answer
32 views

How to check cidr value is valid or not

I am reading CIDR values from the text file, once reading list of CIDR values. I have to validate the CIDR value whether it is valid one or not. How can i Validate the CIDR value is correct or not. ...
-1
votes
2answers
43 views

Variable Scope outside foreach loop Perl

Here is the problem: Generating 10 iterations of 50 iterations and accessing the 50 character string outside the inner foreach loop. I have tried putting the 50x iteration inside a sub function and ...
0
votes
1answer
32 views

LWP::Simple get() fails mysteriously

In http://perlmeme.org/tutorials/lwp.html the first example with LWP::Simple didn't work. I simply copied the code and ran: use strict; use warnings; use LWP::Simple; my $content = get('http://www....
1
vote
1answer
29 views

Symlink two dirs in perl

I have below code for symlink two dirs.. my $Directory = "/data/backups/"; my $symLinkDirectory = "newdisk/data/backups/"; opendir ( DIR, $Directory ) || die "Error in opening directory $Directory\n"...
1
vote
2answers
90 views

Function definition changes the outward behavior of <>

IMPORTANT: The motivation for this question is not to solve a problem, but to understand Perl's behavior. Consider the following toy script: #!/usr/bin/env perl use strict; sub main { @ARGV >...
0
votes
1answer
70 views

Is there a perl equivalent to sed's or vim's `\l` and `\u` in substituting?

in sed(1) & vim(1), there are a set of 'operators' in the regex substitution syntax, \u, \l, \U, & \L. These translit characters to either lowercase, or uppercase. So if one were to type s/(*.)...
0
votes
1answer
42 views

How to pass fuzz logic in head http for perl?

I want to fuzz http parameters using perl, how to do that, please view my sub code. I have tried method using head but I'm getting error. Code from line 620 to 624. sub print_fuzz_methods( ) { my $...
-6
votes
0answers
44 views

How to move files up, from folder-old to folder-new (being the folder-new cd ../..) and doing it in a cycle of folders alphabeticly A to Z [closed]

In a folder "Pdfs" I have many catagories of subfolders from A to Z ("Arts"..."Wood_Furniture") and I want to move the files from /Pdfs/Arts/pdfs/library/files.pdf to /Pdfs/Arts/files.pdf and remove "...
-5
votes
3answers
80 views

Delete lines in File A that begin with a first word of a line of file B [closed]

I have two files. File A looks like this: ... compressionFileThreshold : 1024 defaultSubAccountShardOffset : 1 dynamicAttrLimit : 120 errorConsolidation_reportSpacingParam1Secs : 1200 ...