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
0answers
19 views

Should I avoid using GNU grep's -P option?

The man pages for grep on Ubuntu 18.04 and CentOS 8 have this to say about the -P option for grep: -P, --perl-regexp Interpret the pattern as a Perl-compatible regular expression (...
3
votes
4answers
7k views

How to do a regex search in a UTF-16LE file while in a UTF-8 locale?

EDIT: Due to a comment Warren Young made, it made me realize that I was not clear on one quite relevant point. My search string is already in UTF-16LE order (not in Unicode Codepoint order, which is ...
0
votes
0answers
28 views

execute perl script from a shell script, assign output to shell variable or print to a temporary file

Is it possible to call a script from a inside a shells script, and assign the result of that script to a shell variable? Or print the result of that perl script to a file? sample: #!/usr/bin/sh /...
0
votes
3answers
31 views

Replace the trailing zero's of the date fields in the line

This is my input "004|B20A|2008-09-01 00:00:00.000|C|2008-09-01 00:00:00.070|4277" My output should be "004|B20A|2008-09-01 00:00:00.0|C|2008-09-01 00:00:00.07|4277"
0
votes
1answer
1k views

how to print only Difference in two files using NR=FNR?

we have to print the old entries only Delta(Difference) in File-1 and File-2. newly added enties in files-1 no need to print. on my unix server everyday new report is extracted from system which is ...
1
vote
1answer
60 views

Need help with Perl regex commenting out lines in html

I am trying to comment out a line item entry in a bunch of html documents. I need to match a pattern that has a few variations and the substitution will the be matched pattern surrounded by <!-- -...
0
votes
1answer
36 views

merge values from two files on the same parameters

we have two files - primary.txt and secondery.txt on both files we have the same parameters , but on secondary.txt they are not ordered as the primary.txt more primary.txt param.avarge.com 3443 ...
1
vote
2answers
83 views

Read STDIN with timeout

I want to read STDIN, but at most for 5 seconds. After that I want to process the data I have read so far. select seems to be made for exactly that: Wait until there is input or until timeout. If ...
1
vote
3answers
2k views

How to install Perl modules on Debian 9?

On a tutorial for installing SendEmail, I found instructions to install 2 prequisites, 2 perl modules apt-get install 'perl(Net::SSLeay)' 'perl(IO::Socket::SSL)' This syntax also resulted strange to ...
1
vote
2answers
62 views

Editing the output of fslint with shell tools awk | grep | sed

The task is to transform this text file, output of the utility fslint, into a bash script with rm command lines for the duplicate file(s) to delete and commented lines for file(s) to keep, according ...
0
votes
3answers
61 views

Extract module name and instance name from verilog/System Verilog file

I have a verilog/System Verilog file from which I want to extract only module_name and instance_name. From following single line: module_name #(.ANY_PARAMETER(.ANY_PARAMETER),.ANY_PARAMETER_1(....
1
vote
1answer
78 views

Perl - Not a HASH reference or Can't use string (“…”) as a HASH ref while “strict refs” in use

I'm learning Perl. I am able to iterate over a JSON collection using a Perl hash data structure like this using sample data. However, the actual data contains some elements that are causing either the ...
0
votes
0answers
6 views

How to add additional email validation rules by a python/perl script in Postfix?

In main.cf I have multiple restrictions, as usually: smtpd_NNN_restrictions = # ..... # ..... I want to be able to use an additional python/perl script in each section to make the final ...
0
votes
1answer
39 views

how to separate single json file to pieces of json files

We have the following json ( example 1 ) example 1 more file.json { "version": 1, "partitions": [ { "topic": "list_of_cars", "partition": 2, "replicas": [ 1003, ...
1
vote
3answers
282 views

Replace third word in double quotes from file

This is the json file that we want to edit Example 1 { "topics": [{"topic": "hfgt_kejd_tdsfd”}], "version": 1 } Example 2 { "topics": [{"topic": "hfgt_kj_fsrfdfd”}], "version": 1 } We ...
0
votes
1answer
26 views

Can't locate IO/Pty.pm - but it is installed

I have a script that I inherited from another developer and am trying to make it work on a new RHEL server. The script uses Expect.pm which 'uses' IO/Pty (and IO/Tty). The issue is, when I run this ...
0
votes
1answer
53 views

How to use Perl grep on a hash instead of an array?

I'm learning Perl. I have been able to use grep on an array and the syntax is very simple, like this example: use strict; use warnings; my @names = qw(Foo Bar Baz); my $visitor = <STDIN>; ...
0
votes
1answer
36 views

Does it make sense to do these shell operations in Perl instead of Bash?

I'm learning Perl. I have a trivial application that consists of a bash script wrapper around a Perl script. I am thinking about getting rid of the Bash script and doing it all in Perl (as a learning ...
0
votes
1answer
63 views

How to iterate over JSON object collection (not array) in Perl?

I'm learning Perl. I have been able to successfully iterate over a JSON collection when the objects were contained in an array. However, I cannot understand how to work with JSON data where the ...
0
votes
1answer
27 views

extracting column name and using it to output filename

#chr fivep threep strand sample1 sample2 sample3 sample4 name1 name2 chrI 9442 9492 + 0 0 0 0 na na chrI 12584 12631 + 0 0 0 0 na na chrI 12584 ...
0
votes
1answer
72 views

Delete Hundreds of thousands of files by date [closed]

I want a script that can check the age of files in different directories and delete those that exceed an expiration age. There can be hundreds of thousand of files with different creation dates. Some ...
776
votes
8answers
1.5m views

How can I replace a string in a file(s)?

Replacing strings in files based on certain search criteria is a very common task. How can I replace string foo with bar in all files in the current directory? do the same recursively for sub ...
2
votes
3answers
3k views

Failed dependencies trying to install package 'libxml2'

I am trying to install libxml2, but my system complains about dependencies. The dependent packages exist on system. The ultimate goal is to install xml_grep2, I have been trying various methods (cpan,...
0
votes
2answers
106 views

loop command in a linux file with multiple columns in Perl

I have a file.txt as below with "n" number of columns. I need to run command in loop, that needs to have first column value and the second column value. Upon complete, execute the command to have ...
1
vote
2answers
63 views

Replace multi line string with multi line string without escaping by hand

Say I have a text file text.txt and I want to replace a (multi-line) string that is contained in before.txt with another string that is contained in after.txt, how do I do that? (I dont want to use ...
0
votes
1answer
935 views

how to compare text file datas with excel sheet values

For Example : in my username.txt file ravi peri perl phython in my .xls file i have two columns named as user name and email username email ravi ravi@...
0
votes
4answers
67 views

merge multiple txt files

I have multiple txt files, 3 of them are like: file1: sample input filtered 5809378 1 2 5811151 3 4 5811237 5 6 file2: sample chi tri 5809378 7 8 5811151 5811237 9 ...
0
votes
1answer
52 views

rename fastq.gz file name

I have hundreds fast.gz files, and they have the same format of file name: 5809029_GWU_DNA_269_L001_R1_001.fastq.gz 5809030_GWU_DNA_269_L001_R1_001.fastq.gz How do I change the first and the second ...
1
vote
1answer
24 views

Cron Issue w/ Some Commands and Perl Script

I have searched the Internet for hours for a solution to my issue, and I can't seem to find an answer or solve what I'm doing wrong. I am trying to set up a cron to run a perl script on a regular ...
0
votes
2answers
64 views

how to get sed to replace part of a line that start with a range of numbers

How can I get sed or perl to make the following changes to a line from : 41 * * * * /vend/oracle/util/bin/rmp_udump.ksh to: ##SHUTDOWN_MAINT##41 * * * /vend/oracle/util/bin for all lines that ...
1
vote
0answers
26 views

SNMPv3 traps in Zabbix

My question is about zabbix traps with SNMPv3 and snmptrapd service using zabbix_trap_receiver.pl. I have a switch on which I enabled SNMPv3 only, so the switch has no SNMPv1/2c rw or ro communities ...
0
votes
1answer
18 views

Compiling the output from the Perl Compiler (B::C), I get “EXTERN.h: No such file or directory”

If I try to compile something generated by B::C, $ perl -MO=C,-omyTest.c -e'print "Hello World!";' -e syntax OK And then run `gcc myTest $ gcc ./myTest.c ./myTest.c:3:10: fatal error: EXTERN.h: No ...
28
votes
4answers
44k views

How to “grep” for line length in a given range?

NOTE: This question is the complement of this Q&A: How to "grep" for line length *not* in a given range? I need to get only the lines from a textfile (a wordlist, separated with newline)...
0
votes
1answer
30 views

Missing module for Perl running in Solaris 5.10

I've created a perl script that fetch string/s and output as a file to be loaded on our database. Now, i'm using Solaris 5.10 to run the perl script but there's an error and i think it's referring ...
-1
votes
2answers
44 views

Replace all backslash escape sequence-producable characters with their escaped escape sequences

EDIT: I'm very sorry, that I initially didn't make my requirements clear. I don't actually have access to the string written in a backslash-escaped way and have amended the example to make that ...
0
votes
2answers
47 views

How to extract the key words containing row from an excel file?

I need to extract the key-words containing row from an excel file (.xls) as per the order specified in the given key-word file. For example I have an excel file namely genome.xls as given below, ...
2
votes
2answers
864 views

How to avoid undesirable dependencies in rpm package?

I am making a package for RHEL7. When I try to install the package, I get # yum localinstall mypackage-0.0-1.el7.rpm (...) --> Running transaction check ---> Package webmin-GPI-init.noarch ...
-1
votes
1answer
24 views

NGINX - How to export the entire server block for a given domain

I need a tool or one-liner or whatever, which will export the entire server {...} block containing the given domain. For examples: ### 1) cat conf.d/domains.conf server { include http.conf; ...
0
votes
0answers
37 views

Use Perl to extract multiple arrays and iterate specified arrays

I have a question on Perl. I need to extract arrays and print in the columns below. The tricky part is that each word has different pronunciation types (which is specified in P or S) and each type is ...
0
votes
2answers
60 views

Extract arrays followed with corresponding matches

I am very new to Perl. I need to extract arrays and print in the columns below. The tricky part is that each word has different pronunciation types ( which is specified in P or S) and each type is ...
2
votes
2answers
1k views

Veritus volume manager perl not avaliable

I am trying to install veritas volume manager on Centos 6.5 while running the script its throwing me Cannot find perl to execute
1
vote
0answers
52 views

malware identification found on ubuntu server

I discovered a script running on my server. Reading through apache log files, attacker used cms login vulnerability and downloaded script from this site http://217.61.107.9/wes. Can anybody identify ...
0
votes
4answers
98 views

how to remove New line character using Sed or perl [duplicate]

I have a huge file of XML data containing the lines like <fonts> some of the data </fonts> <fonts> some of the data </fonts> <fonts> some of the data </fonts> <...
3
votes
1answer
1k views

Modify filenames in Makefile

For reasons that are not important here, I have a source code that I process automatically file-by-file and the processed source files are renamed in a systematic manner. For example, I start out with ...
5
votes
0answers
79 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 Devel::CheckLib Net::DNS Mail::DKIM::...
2
votes
1answer
1k views

SFTP Dual Factor Authentication

My Issue I am trying to automate a file fetch from an external [SFTP] server. The server is using 2-factor authentication. First, it needs a public-private key pairing established [This has already ...
43
votes
6answers
87k views

How do you list number of lines of every file in a directory in human readable format.

I have a list of directories and subdirectories that contain large csv files. There are about 500 million lines in these files, each is a record. I would like to know How many lines are in each ...
27
votes
13answers
16k views

Converting CSV to TSV

I have a number of large CSV files and would like them in TSV (tab separated format). The complication is that there are commas in the fields of the CSV file, eg: A,,C,"D,E,F","G",I,"K,L,M",Z ...
1
vote
1answer
77 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">...
25
votes
8answers
43k views

How to delete the last column of a file in Linux

I want to delete the last column of a txt file, while I do not know what the column number is. How could I do this? Example: Input: 1223 1234 1323 ... 2222 123 1233 1234 1233 ... 3444 125 0000 5553 ...