Questions tagged [perl]

Perl is a high-level, general-purpose, interpreted, dynamic programming language. It was originally developed by Larry Wall as a general-purpose Unix scripting language to make report processing easier, over a period with support from open source community, it has evolved and matured to be used for graphics programming, system administration, network programming, finance, bioinformatics, and other engineering applications.

Filter by
Sorted by
Tagged with
3 votes
3 answers
101 views

Perl: change in interpretation of shell symbols in system() invocation?

Today I noticed that something changed in Perl, probably recently, in the way it runs shell commands. Could someone explain what has changed? I cannot find the answer myself and sadly we learned about ...
Kamil's user avatar
  • 1,401
0 votes
2 answers
61 views

perl: replace a string with variable containing new lines (line breaks)

I want to make edits containing meta characters. Here https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed one of solutions is via perl with s\Q ...
Martian2020's user avatar
  • 1,083
5 votes
4 answers
445 views

awk add a column if it doesn't exist

I would like to add a column 3 (description) if it does not exist in a ';' delimited file. example; #Gene;Transcripts;Description;Group gene1;G1a,G1b,G1c;gene1 is a good gene;6 gene2;G2a,G2b,G2c;gene2 ...
alex kiarie's user avatar
0 votes
1 answer
66 views

Check if two IP addresses are in a range

Using bash or perl on a minimal installed Linux, I am trying to validate two IP addresses if there are in a range. I came across a bash script that works well, but the fact that it prints all the IP ...
Bruce Malaudzi's user avatar
4 votes
3 answers
810 views

Renaming files in Linux using perl scripting

I have a set of files with prefix, say "pre_", on a Linux machine and I just want to rename all of these files by removing that. Here is the perl code I wrote it doesn't throw any errors, ...
Sasi Pavan's user avatar
0 votes
1 answer
15 views

View perl module install error AFTER installed

When installing Perl modules (prerequisites for another program), some module showed me an incompatibility warning and said something about needing to downgrade a package. I thought I would get back ...
TSG's user avatar
  • 1,630
1 vote
1 answer
36 views

Error installing perl BerkeleyDB module

I'm trying to install a program which has various perl dependencies. One of the perl dependencies (BerkeleyDB) fails during install. I know very little about perl. Is there a way for me (as a user) ...
TSG's user avatar
  • 1,630
0 votes
1 answer
41 views

Is PERL5LIB setting needed?

I am copying the following systemd service file from an old server to a new one. I'm new to perl, and trying to understand what else needs to move with the service file (aside from the /usr/local/...
TSG's user avatar
  • 1,630
0 votes
0 answers
17 views

Issues when trying to find a file on EFS from an EC2 instance running Perl 5

We have Perl 5 installed on EC2 instance running RHEL 8. When we try and run perl script to located a file on EFS, it takes around a minute to locate the file after it was created on the EFS. There ...
Troy Geri's user avatar
0 votes
1 answer
26 views

Pipe null terminated file paths twice to same output, but second time sorted by basename

So, let's say I have a script that uses find to print paths with null-terminated filenames. I also want to print another version of the output where each path is sorted by its basename. I want to ...
Eduardo Perez's user avatar
0 votes
4 answers
198 views

Remove hostnames from URL with sed/awk

I got lists of urls with different domains and I want the hostname removed with sed, awk or something similar and only keep the path. There are no urls with port or username@password in it. input: ...
pwrsheller's user avatar
-1 votes
3 answers
124 views

How to replace the contents of out.txt with in.txt in a third file?

I have three files, main.txt, out.txt and in.txt. I want to replace every occurrence of the contents of out.txt in main.txt with the contents of in.txt. Both out.txt and in.txt may contain multiple ...
Roger Bosman's user avatar
1 vote
3 answers
719 views

How to deal with CRLF, CR line endings

I have a Perl script that parses data sent to me from a bunch of school districts. I'm adding a new school and have run into a problem I've never faced before. When I do $line = <INPUT>, it ...
Chanel's user avatar
  • 59
2 votes
0 answers
84 views

Processing large blocklists with GNU Parallel

This is an ongoing project that has undergone a major update to speed up list processing. Here is the homepage for anyone interested! It processes lists defined in lists.json by transforming the list ...
T145's user avatar
  • 131
0 votes
1 answer
50 views

How to find the text between the nth occurence of a character and occurence n+1 with perl-rename?

perl-rename 1.14-1 Arch Linux: linux 6.2.12.arch1-1 I have a directory/folder with several subdirectories, all are named by one of the following patterns Status quo of existing patterns something-...
henry's user avatar
  • 844
2 votes
1 answer
170 views

How can I pass variables from a Perl script to a Bash script?

I got the duty to make a fix to an ancient Perl script our company uses, I haven't even looked at Perl in about 20 years. So I want to pick up a couple of the variables, and dump them to the ...
BigHoss's user avatar
  • 21
0 votes
0 answers
133 views

Update package perl-*

I have a linux machine Oracle Linux Server 8.7 with kernel 5.4.17-2136.317.5.3.el8uek.x86_64. Using the yum check-update command, I noticed that there are a number of perl-packages that I can't update....
Kanuc's user avatar
  • 31
0 votes
1 answer
83 views

Change file name based on contents

I'm trying to rename a set of files based on what is in the file itself. I have likely more than a thousand files to rename by the time I'm done. I have code that will get me the first part of the ...
JoJA's user avatar
  • 1
0 votes
0 answers
27 views

ubuntu server 22.04.2 LTS not writing to perl based txt files?

I just installed Ubuntu server to create a home webserver for personal use. I added Virtualmin and my pages and cgi all come up as expected. The problem I noticed is when I attempt to open, write to ...
Tf198's user avatar
  • 1
0 votes
2 answers
108 views

what does syntax .= means in perl

I came across a Perl script which uses following .= syntax $key .= $descriptions[$i]; what does .= means here
Worker's user avatar
  • 37
0 votes
5 answers
105 views

Remove three lines from file until a match

982 01:25:09,473 --> 01:25:10,978 Stay with me. 983 01:25:09,473 --> 01:25:10,978 Stay with me. 984 01:25:15,390 --> 01:25:18,484 ( MAJESTIC MUSIC ) I want to delete three lines below 984 (...
Jakub Fiala's user avatar
2 votes
2 answers
177 views

Perl script to remove repeating header/trailer in file

I have created a perl script to merge 10 file in one. Each file has Keyword header/Trailer in file. So merged file has multiple header and trailer keyword. but I require the header and trailer to be ...
Worker's user avatar
  • 37
0 votes
0 answers
41 views

trouble installing DBD::CSV module on redhat 8

I'm trying to install the cpan module DBD::CSV onto a redhat 8 workstation. In the cpan shell I type: install "DBD::CSV" this runs for a while and finishes like this: ... Appending ...
Greg Matthews's user avatar
3 votes
3 answers
186 views

Print a line matching pattern1 unless next line contains pattern2

I want to match lines that have foo unless the next line contains bar. So given a file containing: 1 foo 1 foo 2 baz bar bap only 1 foo 1 would print. I got this to work using a negative lookahead /...
ScottyChi's user avatar
0 votes
2 answers
171 views

perl has problem if filenames contain dashes

... | perl -pe "s/([^$filespec]*)($filespec)/ ... So I have a function where the above construction works fine if $filespec is most things. However if there's a dash in the file name I get an ...
Ray Andrews's user avatar
  • 2,145
3 votes
1 answer
187 views

Different encoding/Unicode interpretation using terminal vs using shell script

I was working on a keymap script (map keys from one language keyboard layout to another). And after a lot of hard time trying to get everything working I found out that different characters are ...
Andrew15_5's user avatar
6 votes
1 answer
2k views

What are the different versions of the rename command? How do I use the Perl version?

This is a mess. How do I know which command to use when we expect Perl's rename with s/// sed-like syntax, when there're tons of different implementations of rename, that are different versions of the ...
Gilles Quénot's user avatar
0 votes
3 answers
343 views

How to convert seconds to hh:mm:ss.ms when getting difference between 2 times

I performed a calculation that converts current timestamp giving milliseconds as well using perl command such as below: perl -MTime::HiRes=time -MPOSIX=strftime -e ' $now = int(time() * 1000); printf &...
Christopher Karsten's user avatar
0 votes
2 answers
253 views

Remove multiple occurrences using SED command

We had a requirement to remove all /t characters that are not followed by quotes sed 's/\\t\([^"]\)/foo\1/g' this command worked good for single occurrence. What option do we need to add remove ...
Radhe's user avatar
  • 1
0 votes
1 answer
68 views

Missing EXTERN.h file when installing claws-mail on Fedora 37

I've trying to compile Claws-mail but got error: perl_plugin.c:54:10: fatal error: EXTERN.h: No such file or directory 54 | #include <EXTERN.h> I've installed perl-core perl-devel was ...
jcubic's user avatar
  • 9,662
1 vote
2 answers
1k views

How may I replace a string in an XML file?

I am trying to replace the string inside an XML file. From <hello="value" exampleno="xxxx:yyyyyyyy/dd=eeeee-ffffff,aa=bb ccc,dd=eeee,ff=gggg,hh=iii,jj=kkk,ll=mmmm" /> I want ...
Ganesh's user avatar
  • 19
1 vote
1 answer
56 views

How many codes written by perl in debian?

My debian os: cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" ...
showkey's user avatar
  • 99
1 vote
6 answers
508 views

Find and replace a multi line text file in another multi line text file

I fought with it for so long but I am now completely out of ideas. Maybe someone here will be able to help me. Here is what I want to achieve: file_1.txt: # Some comment some_variable="test" ...
Peksio's user avatar
  • 121
3 votes
1 answer
248 views

Using perl's rename to renumber a list of files, starting at a certain value

I'm trying to renumber a list of files, which at a given point in their filename have one index consisting of a four-digit number. These files are consistently output starting from 0001, but need to ...
sam_vh's user avatar
  • 33
0 votes
1 answer
415 views

Writing to unix socket file as fast as possible

I'm trying to write with perl to a unix socket file as fast as possible but failing on full message buffer. I tried autoflush and manual flush without success. use IO::Select; use IO::Socket::UNIX; ...
user496909's user avatar
0 votes
1 answer
155 views

How can I create a .txt file containing data being generated in real-time in Linux terminal when a program is running?

I am running an AutoDock Vina program (using a Perl script) in Linux.  It generates lots of important data (regarding binding free energy of protein-ligand docked complexes).  However, I cannot save ...
Alvea Tasneem's user avatar
1 vote
1 answer
112 views

How can I condense several regex to a one-liner?

I'm having trouble condensing several regex down to an efficient one-liner. I have file names which are named like this: Something (0482) - a123b456 - Something [00xcf bxc v32 Something]. I'd like the ...
telometto's user avatar
  • 1,835
0 votes
1 answer
81 views

clusterssh: prevent windows being arranged alphabetically

I am using cssh on Debian 10 (package clusterssh 4.13.2-2). when I connect to multiple servers: cssh foo bar zz aa cssh will open 4 terminals and ORDERS THEM ALPHABETICALLY !!! So that I get the ...
Martin Vegter's user avatar
1 vote
3 answers
116 views

Detect leaf directories in Perl

For a Perl script I'm working on, I'm looking for a fast and reliable way to find all subdirectories (transitively) of a given directory which are leaves, i.e. those not having any subdirectories of ...
q.undertow's user avatar
5 votes
5 answers
740 views

How can I replace multiple substrings from multiple lines in a file matching a pattern from a different file?

I have a file that contains multiple IP addresses and hostnames, and another file that contains some folders with many IP addresses per line. ip_hostname.txt host1 10.1.1.1 host2 10.2.2.2 host3 10.3.3....
Outsider's user avatar
1 vote
1 answer
41 views

"Total In-/Out- coming connection awareness" - script?

once I had found a bash (or Perl maybe; it's so long ago, that I wasn't knowledgeable about bash enough to tell one set of hieroglyphs from another set so to speak) script that filtered the open files ...
von spotz's user avatar
  • 405
1 vote
3 answers
317 views

Filter git log of pom.xml using regex with grep/perl

I'd like to filter the content of a log of a pom.xml file using a regex. I created it on regexr and it works using PCRE; this is my regex: commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0) I then ...
gscaparrotti's user avatar
0 votes
0 answers
441 views

base64 decode as save as multiple files

I have a file(har file saved from web developer" that contains the base64 encoded value of multiple video*.ts files. I am interested to decode the base64 part and save as multiple ts files if the ...
maneesh murali's user avatar
2 votes
1 answer
440 views

How do you modify the RPM spec file to require perl libraries on centos 7?

I normally start with a Minimal Centos 7 and run yum install perl-libs.x86_64 This works perfectly. I am now trying to create an RPM spec file that uses the "Requires" clause to package ...
user1068636's user avatar
1 vote
1 answer
139 views

Why does Debian package Scalar::Util in libperl and perl-base?

I was just checking something out on Debian, when I use apt-file to search for Scalar/Util.pm a CORE Perl module I see three results, $ apt-file search Scalar/Util.pm libperl5.34: /usr/lib/x86_64-...
Evan Carroll's user avatar
1 vote
0 answers
302 views

how to validate Perl Modules Installed in Ubuntu

I have a list of Perl Modules which needs to be installed on a new server . List of Perl Modules is like this perl-Expect perl-JSON perl-Net-OpenSSH perl-Test-Most perl-DBD-Mock Earlier we were ...
Developer's user avatar
  • 237
0 votes
1 answer
487 views

Perl @INC Path Help

I got handed over a Perl script which fails to run because the path to the Perl is deleted. How can I modify the path such that I can point it to /opt/perl/lib/5.28.2 Any help will really be ...
Rituraj's user avatar
  • 313
3 votes
2 answers
207 views

Find regex occurrances on block device (line length buffer issue)

I'm trying to find all numbers on two block devices that start with a # character, are between 1635700000 and 1653699999, and end either with a null character (\0) or a linux newline (\0xA). I came up ...
user1902689's user avatar
  • 1,178
1 vote
2 answers
163 views

Remove all characters from string, except specific multibyte range

How would one use sed or another tool to remove all characters except a specific multibyte range? For instance, the range \xd8\xa0 - \xd9\x8a covers Arabic characters encoded in UTF-8. This was my ...
dotancohen's user avatar
  • 15.6k
0 votes
8 answers
1k views

Rewriting log parsing script in Perl or Python (get rid of awk)

I need accomplish a task of filtering activity of bots in the log file. Solution should only show records meeting following criteria user logged in, user changed password, user logged off within ...
Twissell's user avatar
  • 141

1
2 3 4 5
27