Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
1
vote
0answers
32 views

inplace file replacement for nth pattern match

I have a file with many lines but I can summarise my requirements like below: <DT><A HREF="http://127.0.0.1:1234/ABCDE/wp-admin/index.cfm?event&msg=secure&fr=sp">...
0
votes
3answers
34 views

sed + set value inside double quotes

The file is like this more /etc/sysconfig/chronyd # Command-line options for chronyd OPTIONS="" We need to set the value -4 inside "" The file looks like the following, # Command-line options for ...
1
vote
3answers
71 views

Why is my perl regex in my bash script not working? MacOS Terminal

I'm trying to move away from AppleScripts for workflows at my job, and create something simpler that can run in the background instead. For this task, I am given 35-40 files (5 renditions of 7 or 8 ...
3
votes
1answer
47 views

Bugzilla error: Can't locate object method quit via package “Net::SMTP::SSL” line 365

I installed Bugzilla on my CentOS 7 web server VPS. The install went smoothly, however when I went to set up email, I received the following error: Can't locate object method "quit" via package "...
-4
votes
2answers
34 views

Create multiple random pairwise combination of words [closed]

File 1 contains the list of words that needed to be randomly paired Tiger Cat Fish Frog Dog Mouse Elephant Monkey File 2 contains the pairs that should not be used (in any solution) during random ...
0
votes
3answers
62 views

how to find the maximum value in specific column every for example 5 lines

How to find the maximum value every 5 lines in a large file. I have file like for example: 186 5 24.0772 24.061 18.5996 2.14E+06 123 4 25.838 29.4805 25.8075 1.25E+06 47 4 24.0637 27....
0
votes
0answers
10 views

Is it possible to install smtp-user-enum on macOS?

I'd like to see if there might be a workaround to install smtp-user-enum on macOS, or does it only have to be installed on Linux? I'm copying the installation part of the documentation below, not ...
1
vote
1answer
49 views

Maximize coverage of a dataset

I have a dataset of the following format. Field 1 lists an identifier, field 3 lists data points, and field 2 counts those data points. id1 5 E1, E2, E3, E4, E5 id2 4 E3, E4, E5,...
0
votes
0answers
23 views

FreeRADIUS Perl Module “Unknown or invalid value ”perl“ for attribute Auth-Type”

I am attempting to setup a FreeRadius Server with an OTP (LinOTP) backend in Centos 7. My issue is loading a perl module needed to link FreeRADIUS to LinOTP. No matter what I try I just keep getting ...
-1
votes
0answers
25 views

Recover a deleted file not listed by lsdel?

I am trying to recover a file accidentally deleted, but when I follow the procedure with debugfs, it shows me a handful of deleted files from 2 months ago. How do I resolve that or what are my other ...
1
vote
1answer
47 views

How to find max value from specific XML element using a Perl one liner?

I have an XML file with the following syntax <element> <id>0</id> <tag1>something</tag1> ... <tagn>something</tagn> </element> <element> ...
4
votes
3answers
833 views

How to add the real hostname in the beginning of Linux cli command [duplicate]

we have redhat servers - 7.2 the following output from sar print all relevant details as the following sar -p -d 1 1 07:16:35 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz ...
-1
votes
3answers
59 views

Mapping readings with labels [closed]

Given a list of readings in the following format: 1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0 1 1 0 0 2 2 23104 23104 0 0 1 0 5 1 0 0 What would be an approriate (and clean !) way to map them to their ...
8
votes
5answers
1k views

Removing rows containing NA in every column

I have a tab delimited file which looks like this: gene v1 v2 v3 v4 g1 NA NA NA NA g2 NA NA 2 3 g3 NA NA NA NA g4 1 2 3 2 The number of fields in every line is fixed and ...
2
votes
2answers
80 views

Does the order of command line options matter in Perl?

The following command works as expected: perl -lne 'print $1 if /install\(TARGETS (.*) RUNTIME DESTINATION bin\)/' CMakeLists.txt This one works as well: perl -nle 'print $1 if /install\(TARGETS (.*...
0
votes
0answers
66 views

Why might a perl CGI script fail to connect to MySQL, when it works from console?

I'm migrating to new server hardware, which also means learning the idiosyncrasies of a new Linux distribution (Debian buster). I've got a Perl CGI script which when run from the console runs, but ...
-2
votes
2answers
57 views

command to summarize a cluster of entries in a table

I have a table that shows how many ASVs(columns) are clustered in one OTU(rows). Each ASV is represented by a value of 1. #OTUID ASV_1 ASV_2 ASV_3 ASV_4 ASV_5 ASV_6 ASV_7 ...
3
votes
4answers
353 views

Extract specific characters from each line

I have a text file, and I want extract the string from each line coming after "OS=" input file line A0A0A9PBI3_ARUDO Uncharacterized protein OS=Arundo donax OX=35708 PE=4 SV=1 K3Y356_SETIT ATP-...
0
votes
2answers
50 views

merge 1st column and 2nd column; 3rd and 4th column and so on with a separator

I have a text file with 61000 columns and 173 rows. I would like to merge data on every 2 columns i.e., columns 1 and 2 should be merged, 3 and 4 should be merged, 5 and 6 should be merged and so on. ...
0
votes
2answers
66 views

Replace a command with the result (command output) in the line using sed

Is it possible to replace a command extracted by some regex with its output using sed? For example, I have the next file: 2 + 2 = $$shell:echo 2 + 2 | bc$$ // and "some unescaped text' here how I ...
2
votes
1answer
43 views

compare columns from two different files and PRINT RECORDS FROM FIRST FILE those that DO NOT match from second file

I would like to compare columns from file one to two. Where column 2 of file1 should un-match from column 1 or 2 from file2 and print output from file 1. file1. cat test.head20.R2.fastq.tab @...
1
vote
2answers
28 views

Unable to use Perl join properly to append something to each occurrence - getting “Array found where operator expected at” error

I have log lines like these - /mnt/internal-app/logs/internal-app.log_2019-08-21.log.gz:2019-08-21 07:31:14,153 5458142 [XNIO-3 task-4] INFO c.c.p.i.m.ws.FileManger [FileName.java:1838] - UUIDs in ...
1
vote
3answers
24 views

insert strings/words to variable from file and join separator instead of space/s

We have the following file ( it is example ) more machines.txt Node23 Node34 Node12 Node95 Node23 We want to insert the list of all node to variable and join each node with “,” separator Example ...
4
votes
1answer
83 views

Printing PDF using Perl

I've got a script that creates a PDF and sends it to remote print server running CUPS. Using Net::Printer, I set up the printer: my $print_server = "remote_print.server"; my $printer ...
3
votes
3answers
35 views

Rename to remove everything after a special character

I recently discovered the perl-based rename function but since I don't know anything about perl I can't use it properly. I found of a lot of question about the subject but nothing helped me. I would ...
1
vote
0answers
39 views

Computing pair-wise time differences in mili seconds between matching records in a data table

I have a three-column table of data of the following form: TIME MPID CPID 14:00:04.909 10048 370007 14:00:05.320 10048 370007 14:00:05.462 10048 370008 14:00:05.761 10048 370008 14:00:...
3
votes
7answers
477 views

Print only the last three columns from file

I have this file on Linux: 14:00:01.071 5255 604177 4 14:00:01.074 4608 1415742 14:00:01.074 18398 1122001 2 14:00:01.074 11723 155575 5 14:00:01.075 4695 885808 Desired Output: 14:00:01....
2
votes
2answers
59 views

Remove values from NUL separated file

I have an array of values v that I want to remove from the file f. f is NUL delimited. How do I proceed? I tried using sd, but it didn't work. Example: I have this file: # cat -v $attic ^@this is 1....
1
vote
5answers
83 views

Editing a file in place using perl or awk

I have a large tab-delimited input file listed as below SF_0000000555_RDNAU_58_10293 10873 11041 + ID=match41;Target=SF_0000000005 99 267 168 SF_0000000555_RDNAU_58_10293 188079 ...
0
votes
1answer
47 views

Perl.cgi soap request HTTP ERROR 411

I'm trying to learn SoapUI, but when running the code below I'm getting HTTP ERROR 411 all files are in /var/www/html/ not sure what's the issue. #!/usr/bin/perl use SOAP::Transport::HTTP; SOAP::...
0
votes
2answers
51 views

How to extract a range of number from two files?

I'm trying to extract the number range from two files. $ cat file1.txt chr1 69509 chr1 69511 chr1 71000 chr1 358112 chr1 586874 chr1 744200 . . . $cat file2.txt chr1 69091 ...
0
votes
1answer
39 views

Autostart pure-ftpd by running its Perl configuration file at the command line

I have manually built the pure-ftpd on my Raspberry Pi and it runs perfectly fine when I invoke /etc/pure-config.pl /etc/pure-ftpd.conf from the command line. I'd like to run that simple command /...
1
vote
0answers
22 views

How to create a custom Perl distribution

I would create a custom Perl distribution for perl-5.30.0.tar.gz. I would include in the perl-5.30.0.tar.gz following Perl modules HTML::Entities HTML::Strip Convert::Scalar Unicode::LineBreak ...
0
votes
1answer
42 views

How does pcregrep works?

I have a file: This error -this -this -that [text I want] This error -asd -asfag -adsfhs [text I want] [text I want] This error -asdgsda -asdgg -gasdg I want to match to match except This error and ...
0
votes
1answer
60 views

bash + grep only the time stamp from output

we want to capture the time from the output and not the time from the command sshpass expected output Sun Jul 14 12:47:49 UTC 2019 Sun Jul 14 12:47:49 UTC 2019 Sun Jul 14 12:47:49 UTC 2019 but from ...
0
votes
0answers
27 views

Getting error while running the shell script

CURRTIME=$(perl -e ' print time(), "\n"') FILETIME=$(cat timestamp.txt ) TIMEDIFF=$(($CURRTIME - $FILETIME)) I need to add 1 second to FILETIME variable, even if there is no entry in timestamp.txt, ...
1
vote
2answers
56 views

Convert Excel file to PDF using Perl CGI

I'm trying to convert an xlsx file to pdf using Perl CGI (Mason). Since I did not find a way to convert a file using pure perl, I'm using soffice to perform the job. This works fine until I do it ...
0
votes
0answers
77 views

pssh + verify date between machines and alert if date difference is more then 3 second

we are using the following great pssh command in order to see if time differences is more then 3 second between machines pssh -i -o /tmp/out/ -e /tmp/err/ -H "master01 master02 master03 worker01 ...
1
vote
1answer
69 views

How to uninstall orphan Perl packages?

pacman this morning reported the following: WARNING: '/usr/lib/perl5/5.28' contains data from at least 4 packages which will NOT be used by the installed perl interpreter. -> Run the ...
0
votes
1answer
83 views

Perl regex matching apostrophe fails

I'm trying to write a Perl script to transform several sripts into a canonical form. I expected the script #!/usr/bin/perl -W use File::Spec; use Getopt::Long 2.3203 qw(:config auto_help auto_version)...
1
vote
1answer
85 views

Is this a good way to extract the name of a script?

My situation is this: I want a Perl script to say its own name. I tried print "$0\n"; which is a good solution if you are working in the same directory were the script is. I find this solution use ...
1
vote
1answer
62 views

Convert XLS file to CSV file in perl without using spreadsheet [closed]

I have a file in .XLS format and I want to load that file on Informatica, for which I need to convert that file to .CSV, i.e. XLS to CSV.
-2
votes
2answers
44 views

Perl::Find a substring and display a whole word

I have a text file that has some data like: PADHOGOA1 IOP055_VINREG5_1 ( .IO(VINREG5_1), .MONI(), .MON_D(px_IOP055_VINREG5_1_MON_D), .R0T(px_IOP054_VINREG5_0_R0T), .IO1() ); PADV30MA0 ...
1
vote
1answer
105 views

Escaping special characters &, $, ^, *, ! in unix command (bash perl)

Basically, I'm trying to send some email thru uucp to some especial accounts using the RFC 5322 standard that includes !#$%&'*+-/=?^_`{|}~; (https://en.wikipedia.org/wiki/Email_address#Local-part) ...
1
vote
3answers
137 views

Perl: Inserting at nth position in file

I have content in my file : 123456789 My output is: 1234CC789 Desired Output is: 1234CC56789 I am insert PP at nth position suppose. But when I am inserting any text it is inserting the text at ...
0
votes
1answer
35 views

Extract pattern in perl

Is it possible to have just one regex which can extract the pattern "Mango-1.whatever.." in any of these 3 conditions (i.e. $dummy). I keep printing everything after this pattern. If I use comma in ...
0
votes
2answers
61 views

REGEX: flush a number of related chains in iptables

I want to flush a number of related chains in IPtables. Their names like 'f2b.*' I want the entire chain gone! e.g. all this gone. -A f2b-postfix-sasl -s 103.231.139.130/32 -j REJECT --reject-with ...
0
votes
1answer
27 views

Split and store in Perl

I have a file with this content: Ref BBPin r:/WORK/M375FS/HMLSBLK4BIT0P0_0/LSVCC15 Impl BBPin i:/WORK/M375FS/HMLSBLK4BIT0P0_0/LSVCC15 Ref BBPin r:/WORK/HMLSBLK4BIT0P0_0/LSVCC3 Impl ...
0
votes
1answer
40 views

File read, compare and replace based on comparison in text file

Hi i need guidence to write code for file processing. i have one file which having ~ as delimeter and each line is keyword is 1st column. First i have to find the lines which matches with ^6999 Then ...
0
votes
2answers
92 views

How to Aggregate and get group count in specific column from text file by perl?

I have a big text file(with 15 lines) in this format (srip dip sport dport .....) I would like to group distinct first column and get the group counts, input file: 10.10.10.1 10.10.66.150 60761 502 ...