Skip to main content
The 2024 Developer Survey results are live! See the results

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
0 votes
0 answers
17 views

Where are Perl arrays @0, @9999 documented?

$ perl -wle 'my @388=0..2;' Can't use global @388 in "my" at -e line 1, near "my @388" Execution of -e aborted due to compilation errors. $ perl -wle '@388=0..2;' $ Where can I ...
Dan Jacobson's user avatar
1 vote
0 answers
19 views

Problem enabling perl module stream AlmaLinux 8.10

I have an issue with our AlmaLinux 8.10 systems that they suddenly have issues with perl dependancies. It tuns out that the current active perl stream is 5.26 (dnf module list perl*) but some packages ...
Stefan Lelieveld's user avatar
-1 votes
3 answers
90 views

Delete 2-line paragraphs, keep 3-line paragraphs, maintain newline between all

On a Linux machine with GNU tools I have an ascii file that consists of only 2-line and 3-line paragraphs, each paragraph separated by a newline. All 2-line paragraphs are to be deleted so that all 3-...
stampeder's user avatar
0 votes
1 answer
46 views

version `XCRYPT_2.0' not found after Update Debian 10 to Debian 12

I was instructed to upgrade Debian 10 to Debian 12. After the upgrade, I noticed that the ssh.service was not working. Now I found out that no 'apt' commands work. I can't install anything. Here the ...
Szymon Tesmer's user avatar
16 votes
5 answers
1k views

How can UserA programmatically replace a text string within a file they own that's located in /etc?

A non-root linux user owns a text file that's located in /etc, where the non-root linux user does not have permission to create files. The non-root linux user can edit the file manually via vi without ...
Tortoise Pirate's user avatar
0 votes
1 answer
40 views

What does the line ($eachJOBID = $eachScriptNoPath) =~ s/\.csh// ; do?

This line I have in my code cuts the .csh from a string and returns the rest of it. Can someone explain what each part of it does? ($eachJOBID = $eachScriptNoPath) =~ s/\.csh// ;
manylya's user avatar
1 vote
3 answers
73 views

Bash: sum a number present in N lines before a given pattern

I have a kdenlive project file (which is basically a xml file) with a lot of text clips inside. I need to bulk edit the x coordinate of a certain text that appears multiple times. This is an example: ...
baiserekku's user avatar
3 votes
1 answer
474 views

Why is one process ps command showing spaces around a directory instead of slashes?

I'm trying to debug a failing legacy process monitor that searches processes that are running. I determined it is being caused by some mysterious linux behavior. The process being ran is /opt/my/path/...
k.schroeder31's user avatar
1 vote
1 answer
54 views

how to catch output from a subprocess?

I am trying to catch the password prompt of sftp, but somehow it is not from STDIN or STDERR. It possibly comes from a sub-process. The following is my test. I tried to redirect the password prompt to ...
oldpride's user avatar
  • 231
0 votes
1 answer
33 views

AWStats stuck, but no output on strace: How to debug?

A Perl script is stuck, root 1317478 99.8 0.0 264072 22516 ? R 04:57 478:37 /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=domain.tld-http -staticlinks -configdir=/...
Thomas's user avatar
  • 23
6 votes
3 answers
647 views

awk: sort by first column then second; output unique 1st column once but all 2nd column

I have a two-column file that you can create as follows cat > twocol << EOF 007 03 001 03 003 01 137 12 001 11 002 01 002 02 002 03 001 02 002 04 137 94 010 21 001 01 EOF The resultant file, ...
bballdave025's user avatar
0 votes
1 answer
72 views

How to combine ...if $x and a here-doc in perl? [closed]

How is one supposed to write this? print <<EOF; if $x bla EOF I think it is called postfix notation, and a here-doc. I get a syntax error. OK, I guess I'll just use print "bla" if $x; ...
Dan Jacobson's user avatar
3 votes
7 answers
434 views

How can I print the longest sequence of lines featuring numbers smaller than a threshold?

I am learning Perl, but I don't know how to solve this problem. I have a .txt file of the following form: 1 16.3346384 2 11.43483 3 1.19819 4 1.1113829 5 1.0953443 6 1.9458343 7 1.345645 8 1....
69 420 1970's user avatar
2 votes
1 answer
25 views

How to use `perldoc` within Emacs (shell)?

While programming using Emacs, you frequently consult manual pages. My environment is text-based Emacs via SSH. While I can open "Normal" manual pages in Emacs using the man command ((man ...
U. Windl's user avatar
  • 1,493
1 vote
1 answer
46 views

Search and replace content

PIN A 1 1:3 0:8 0 0:0 PIN B 1 1:0 0 0:0 Z Z:0 PIN C 1 1:3 0:8 0 0:0 Z Z:0 I would like to change the content on PIN A & PIN C only without affecting PIN B to 0 0:3 Z 0:3 Can't seem to find a ...
JSL's user avatar
  • 11
1 vote
1 answer
51 views

Report sed changes + corresponding perl syntax

Newbie learning Linux and perl: I would like to (a) search-replace strings, (b) match filename pattern .myfile., (c) look recursively in subdirectories, and (d) print the line number, file name, ...
Susie's user avatar
  • 13
1 vote
7 answers
314 views

Find all lines between two patterns, EXCLUSIVE of the second pattern?

Consider that I have the file listed below. I need to select all lines from every instance of the regex pattern Word A to before the regex pattern Word D. Word A Word B Word C Word D Word E Word F ...
RonJohn's user avatar
  • 1,154
0 votes
1 answer
30 views

getting started with PDL for cluster analysis PDL::Stats::Kmeans

I guess first up is the Question " is perl data language dead ?" I'm not finding any active discussions or user q&a sorry for not tagging this better I dont have the rep' my problem area ...
aldobranti's user avatar
4 votes
0 answers
47 views

Perl's `kill` is using `$! == Errno::EINTR` unexpectedly

I wrote a network daemon that forks off children to handle TCP connections. On SIGINT the main process triggers a kill for each child in order to clean up and to collect some final statistics. In ...
U. Windl's user avatar
  • 1,493
2 votes
3 answers
822 views

ARGV[] not accepting the argument

I have a shell script that I am trying to pass a date argument to ARGV[1] but the script is giving a blank output Here is the command: #!/bin/bash dt=$(date -d "yesterday" '+%m%d%Y') cat /...
NecroCoder's user avatar
4 votes
4 answers
2k views

Ist it possible to check the peer address before accepting a TCP connection?

I wrote a simple Perl server that listens on a TCP port/socket, accepting connections. Now I wonder: When wanting to implement address-based access control, is it possible to check the address of the ...
U. Windl's user avatar
  • 1,493
-2 votes
3 answers
120 views

bash + how to verify folders under specific path are ended with number/s

I want to check the folder/s under /var/kafka that all them are ended with number otherwhile I will exit with error ls -ltr /var/kafka drwxr-xr-x 399 kafka kafka 28672 Nov 9 13:10 data6 drwxr-xr-x ...
yael's user avatar
  • 13.4k
0 votes
2 answers
60 views

rename - move [ ] delimited part of filename to end of filename

I've been playing with the perl implementation of the rename tool in cygwin having finally got it working via installing from cpan. It's been a long time since i played with this stuff so I'm a bit ...
Adam B's user avatar
  • 3
2 votes
4 answers
212 views

Parse text file add semicolons before and after numbers; join all other words that are before/ between numbers with hyphens

I have a text file with accounts like: Input Sample Paid 100 15/02/2022 3000 recd 50 15/02/2022 nelur trip 3050 PAID 80 25/03/2022 Adjusted towards trip 3130 14 PAID 50 26/03/2022 Given to Nate Cash (...
tgkprog's user avatar
  • 249
0 votes
1 answer
478 views

How to remove characters from end of a line till a particular character in perl

my string is like $varin="wer.try.iuy.oiu.qert" i wanted to remove characters starting from end of the string till "." is encountered. expected output: wer.try.iuy.oiu have tried ...
Taylor_Sharma's user avatar
-1 votes
3 answers
152 views

Replace new lines at end for those lines whose 2nd field in colon separated file span over to multiple line

I have got multiple files with different set of contents but the pattern is same across mulitple lines in different files. sample input file : cat -n test.txt 1 adjfkhjdhfkjd: ...
Ashis Sahoo's user avatar
2 votes
1 answer
395 views

int seems to be not int in a used perl library

A peculiar phenomenon is on my mind. As you may know, dealing with a mail server directly exposed to the internet can be quite the 'joy' with various individuals attempting to break into it or use it ...
numchrun's user avatar
  • 508
8 votes
3 answers
990 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,491
0 votes
2 answers
312 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,219
5 votes
4 answers
699 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
538 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
1k 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
66 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,768
1 vote
1 answer
239 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,768
0 votes
1 answer
565 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,768
0 votes
1 answer
31 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
663 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
132 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
2 votes
3 answers
4k 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
  • 99
2 votes
0 answers
101 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
  • 213
0 votes
1 answer
77 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
  • 914
2 votes
1 answer
398 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
435 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
  • 41
0 votes
1 answer
202 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
41 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
131 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
118 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
251 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
3 votes
3 answers
207 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
277 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,537

1
2 3 4 5
28