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 ...

learn more… | top users | synonyms

1
vote
1answer
18 views

Perl script to split a file based on a pattern at a certain offset

I need your help to get an idea as to how to split a large file into small sub-files as said in the example below. Criteria is we are looking at offset 30 (31st bytes to 2 bytes). If the offset ...
-4
votes
0answers
25 views

PERL SCRIPT ERROR (DBD ERROR: error possibly near <*> indicator atrror possibly near <*> indicator at char 53 in 'insert [migrated]

i am getting below error while running below perl script. Can any body help to figure it out` $ENV{PATH}= '/appl/OMS/scripts:/etc:/usr/bin:/usr/sbin:/b... $ENV{PATH}= ...
4
votes
1answer
359 views

How do I sort words by syllable count?

How do I perform an ascending sort of a word list, based upon how many syllables each word contains? Example Input: something important dog cat bookshelf Example Output: dog cat something ...
8
votes
6answers
12k views

How to grep for text in a file and display the paragraph that has the text?

Below is the text in the file: Pseudo name=Apple Code=42B state=fault Pseudo name=Prance Code=43B state=good I need to grep for "42B" and get the output from the above text like: Pseudo ...
0
votes
0answers
171 views

error for installing Math module CDF in perl

I am trying to install Math::CDF in perl I tried both cpan -i Math::CDP and install from downloaded files both end up in error after enter make install: Running make install make[1]: Nothing to be ...
2
votes
3answers
176 views

sed regular expression behaving differently than in vim and perl?

Here's a sample 'test.txt' abcdX1yad45das abcdX2fad45das abcdX3had45das abcdX4wad45das abcdX5mad45das sample desired output: X1yad X2fad X3had X4wad X5mad I could get it working in vim with: :% ...
3
votes
4answers
59 views

Find matches on adjacent lines

I want to find adjacent matching lines, e.g., if the pattern matches are $ grep -n pattern file1 file2 file3 file1:10: ... file2:100: ... file2:1000: ... file2:1001: ... file3:1: ... file3:123: ... ...
1
vote
1answer
29 views

Using Perl for Even/Odd numbers

Currently, I'm using a process to create a very specific set of four files. The Process I'm using is shown in the attached Process Image, below: The first line is part of a solution, given to a ...
0
votes
1answer
19 views

Perl code to refer to multiple file of the same extension (.xml)

I'm trying to parse multiple xml files but i'm a bit stuck with something. The $twig->parsefile("output_1.xml"); section of the below script works fine in parsing the file stated. However, I would ...
1
vote
2answers
49 views

I want search for a string and to pull all the lines between two patterns [duplicate]

I want search for a string and to pull all the lines between two patterns(including the pattern). START#1 Name S 101 Frankfurt_1_1 19 A+ Street END START#2 Name B 104 Berlin 20 A+ ...
3
votes
2answers
87 views

Search, insert, move and insert

I want to search each record (records are defined by blank lines) in a file for the pattern NAME#AAAA. If it matches, then insert an # in front of the record's AGE line and move that line to the top ...
0
votes
0answers
20 views

search insert and replace [duplicate]

I want to search each record (records are defined by blank lines) in a file for the pattern NAME#AAAA. If it matches, then insert an # in front of the record's AGE line and move that line to the top ...
1
vote
0answers
24 views

“cli” command in not working when passing through “Net::SSH::Perl”

This is my code : my $ssh = Net::SSH::Perl->new("$hostname", debug=>0); $ssh->login("$username","$password"); my $cmd = "cli version"; ($stdout,$stderr,$exit) = $ssh->cmd("$cmd"); print ...
238
votes
6answers
461k 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 ...
1
vote
2answers
17 views

text to find and replace in all files and in all directories

I want to replace all occurrences of 1800 102 6022 with 1860 266 2666 in all files. I have different files in different directories which can contain 1800 102 6022. I am using: perl -pi.13.04.2016 ...
0
votes
1answer
51 views

How do I calculate the column percentage of a file?

I have a tsv file that contains some values. I want the sum of each column and total number of values and percentage values. Eg: file.tsv contains x 1 1 0 1 x x 1 x ...
0
votes
1answer
972 views

AWStats on Debian Jessie Forbidden from Browser / Unresponsive from CLI

I asked this on SO a day or two ago and no response yet. Hoping for some insight here in getting AWStats configured and running on Debian Jessie. Installed AWStats with apt-get install awstats. No ...
0
votes
1answer
40 views

SSH into another VM via Perl / Sh script failing. Works manually

I want to run a Perl CGI script (a_web_page.cgi) from my dev box .1.20 that runs a bash script from the same folder (host_script.sh). This script then runs a SSH command to another server 1.10 that ...
0
votes
1answer
431 views

Issue with installing CPAN XML::RSS

I'am running debian on my server and want to install the CPAN module XML::RSS. But I get this error: http://pastebin.com/5syPaQfe (Pastebin because it's really long) I'am trying to install ...
1
vote
1answer
3k views

“Requires: perl(:MODULE_COMPAT_5.8.8)”

I use CentOS 6.5 for my server with below repository: IUS epel ces-standard-* base/upgrade/extras When I tried to update today (it's been a while I haven't updated this server), I got the ...
0
votes
1answer
21 views

How to replace a text with another in Perl

Using tr command I want to convert Hello into Hii. My command was: $_="Hello"; print; tr/Hello/Hi/; print; But the result was Hiiii. What did I do wrong? What is the right way to do it?
0
votes
2answers
51 views

Help in making multiple lines as single lines

I have below 4 lines: EXTRACT ETEST Last Started 2016-03-20 20:56 Status RUNNING Checkpoint Lag 00:00:02 (updated 00:00:04 ago) EXTRACT PTEST Initialized 2016-03-31 06:25 Status ...
6
votes
4answers
24k views

compare two columns of different files and print if it matches

I am using solaris 10 and Grep options involving -f doesnt work . I have two pipe separated files: file1: abc|123|BNY|apple| cab|234|cyx|orange| def|kumar|pki|bird| file 2 : abc|123| ...
1
vote
2answers
48 views

SED Search and Replace on Linux [duplicate]

I want to change the value from 1521 to 1525 in FROM_HOST only in file gexhosts.cat: FROM_HOST db201521 TO_HOST db201521 Is there a way to do that or some work around? I would really prefer ...
0
votes
3answers
31 views

Perform regex search on a previously regex-matched line (one-liner)

I need to print a string which is in a unique line in a long text file. Example relevant line in file long.txt: Software version 4.0.10, 2002-03-28 The wanted string is exactly 4.0.10. The steps ...
0
votes
2answers
2k 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 ...
3
votes
3answers
81 views

Replace strings in a file based on a list of strings and a list of corresponding replacements

I am trying to replace strings in a file A: Hello Peter, how is your dad? where is mom? where the strings to be replaced are in file B: Peter dad mom and their corresponding replacements are in ...
1
vote
3answers
43 views

Count occurance of number and delete line of matches value

Could I get some help please with my problem? I have a file that looks like this (comma separated): A,250,13,820,0,80,201 B,0,0,0,0,3,0 C,0,2,1,0,0,0 D,0,1,105,0,0,10 I would like to ...
4
votes
0answers
42 views

Perl one liner to find words longer than 63 characters

I have a number of xml files containing sanskrit texts to be converted to tex. Latex has a maximum of 63 characters per word for its hyphenation to work, everything longer than that will not be ...
27
votes
3answers
19k views

What does ${1+“$@”} mean in a shell script, and how does it differ from “$@”?

In the Perl documentation, perlrun(1) suggests launching Perl scripts using a bilingual shell/Perl header: #!/bin/sh #! -*-perl-*- eval 'exec perl -x -wS $0 ${1+"$@"}' if 0; What does ${1+"$@"} ...
-1
votes
3answers
71 views

Shell scripting : want to login on some server, which are in same domain and execute command and exit

I have 10 unix servers, I want to log into them one by one, execute 4-5 lines of code, save the output and exit. For Example: 10 serves: Intially at xyz server Login in server 1 --> execute 4-5 ...
-3
votes
1answer
43 views

Meaning of this perl command [closed]

I found this command perl -ne 'print $1 if m/\.([^.\/]+)$/' and I'd be very grateful if someone familiar with perl could tell me in a nutshell what exactly all the syntax means, it would save a lot of ...
0
votes
0answers
24 views

perl script stall nanosleep() call in strace output

I have perl base SIP client which calling for SIP REGISTRATION process but i am seeing it stall for 10 second at nanosleep() call send(4, "REGISTER sip:sip.example.com S"..., 513, 0) = 513 select(8, ...
3
votes
4answers
88 views

How to delete a specific number in file?

I have a file: 1 2 5 6 8 0 0 0 0 1 2 5 6 8 0 0 0 0 1 2 5 6 8 0 0 0 0 1 2 5 6 8 0 0 0 0 I want delete all zeros: 1 2 5 6 8 1 2 5 6 8 1 2 5 6 8 1 2 5 6 8 I tried tr -d [:0:]. Unfortunately, it ...
3
votes
1answer
267 views

How to print incremental count of occurrences of unique values in column 1

I'm trying to come up with an solution to this problem, I need to incrementally count and then print the counts of the unique values in column 1 of a tab delimited text file. Here is an example: ...
0
votes
0answers
11 views

No 'Makefile' created KAMENSKY/Text-Bidi-2.11.tar.gz [duplicate]

I am trying to install following perl module via cpan on centos 6.x but unfortunately getting error. Please advise to solve. Text::Bidi Version: 0.03 Usage: Label batch PDF CPAN /usr/bin/cpan ...
0
votes
1answer
55 views

No 'Makefile' created KAMENSKY/Text-Bidi-2.11.tar.gz

I am trying to install following perl module via cpan on centos 6.x but unfortunately getting error. Please advise to solve. Text::Bidi Version: 0.03 Usage: Label batch PDF CPAN /usr/bin/cpan ...
3
votes
1answer
96 views

Bash script can't locate perl module

I have a shell script which isn't running menutray on i3 startup. Line in .i3/config: exec ~/.i3/i3-scripts/menutray.sh This is what I tried for debugging: #!/bin/bash menutray -i -u -r ...
0
votes
4answers
51 views

Extract ranges of lines from a file, saving each range to a separate file

I have a file that looks like this 740*02/01/2016*00:00* EJ LOG COPIED OK AUTO INIT COPY DRIVE NOT CONFIGURED E1EF3901 [020t*741*02/01/2016*05:45* *TRANSACTION STARTED* [020t CARD INSERTED ...
4
votes
3answers
373 views

How to replace a multi line code with sed?

I have a large file which has special characters in it. There is a multi line code there, that I want to replace with sed. This: text = "\ ------ ...
1
vote
2answers
1k views

perl library getopts.pl

I'm trying to install a program, but keeps giving an error saying it doesn't find the perl library getopts.pl. My perl version is v5.16.2. The error message is: Can't locate getopts.pl in @INC ...
0
votes
6answers
79 views

Merge multiple lines in same file based on column 1

I'm still learning programming and I've tried many things but just cannot get the correct format. I have a tab delimited file with 17 columns and many (around 50.000) rows. The file is already sorted ...
4
votes
2answers
104 views

Why doesn't my Perl play nice with Unicode?

On my new Arch installation, perl doesn't seem to play nice with Unicode. For example, given this input file: ελα ρε 王小红 This command should give me the last two characters of each line: $ perl ...
1
vote
2answers
56 views

Why does perl regex find pattern \\label\{.*?\} but not \\ref.*?\} or \\autoref\{.*?\} in TeX Files?

I am using perl to parse many multilingual text files. I need to change the text between two patterns: Desired Changes For example, the English original version looks like this: \label{whatever} ...
0
votes
0answers
49 views

Koha-3.22.02 Installation error on CentOs

After downloading and extracting koha-latest.tar.gz I am trying to install Koha-3.22.02 on CentOS 6.x. Following are configurations and errors. How can I solve it ? Configurations, Versions ...
2
votes
4answers
765 views

How to calculate the sum of the data that have the same ID in the first column?

I want to sum the values of the rows of my data that have the same ID in the first column. My data looks like data.txt Id a b c d e 1 1 2 3 4 5 1 2 3 4 5 ...
1
vote
2answers
240 views

Which of /usr/bin/perl or /usr/local/bin/perl should be used?

If I have both /usr/bin/perl and /usr/local/bin/perl available on a system, which one should I use?
0
votes
4answers
48 views

Print only unique lines from file not the duplicates

I have a sorted words list, line by line file like so: apple apple grapes lime orange orange pear pear peach strawberry strawberry I only want to print out unique lines and drop duplicates: grapes ...
2
votes
3answers
243 views

Can I use the find command to pass arguments to perl?

I have a perl script $ cat ~/script.pl sub main { my ($file) = @_; <STUFF> } } foreach (@ARGV) { main($_); } I want to execute ~/script.pl on every .txt file under the ...
1
vote
1answer
77 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 ...