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

0
votes
0answers
5 views

Group Already Exist [migrated]

#!/usr/bin/perl use strict; use warnings; my $group_name = <STDIN>; my $group_id = <STDIN>; my $choice = <STDIN>; print "* My menu *\n"; print "* *\n"; print "* 1. Create a ...
4
votes
1answer
27 views

grep variable-length optional text

I would like to search for edge-anchored text that has a block of preceding optional text, any amount of which can be included in the match. For instance, supposing I am trying to find ^xyz but would ...
0
votes
2answers
46 views

how to remove all double quotes from csv except specific field

I want to remove all double quotes from my csv but not the fourth field (because the four fields represent PATH of file) Please advice how to implement this by sed or awk or perl one liner , etc ...
-2
votes
0answers
25 views

Modify Perl Menu [closed]

Here is my code so far: #!/usr/local/bin/perl -w use strict; use Cwd; while ( 1 ) { print "\n COMMAND MENU\n"; print "\n a. Current date and time\n"; print "\n b. Users ...
1
vote
0answers
25 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 ...
5
votes
2answers
268 views

How is the inplace modification of a file being done?

What does the "inplace" modification of a file e.g. via sed -i or perl -i mean? My question is about how this inplace modification is done. Is the file copied the modification is done in the copy and ...
2
votes
2answers
104 views

Format the content of the file using Perl

I am new to Perl programming and I am stuck with this problem for some time. Can you please help me in solving it? I have a file with the following format: >Country1 Aus trali a >Country5 ...
0
votes
0answers
4 views

How to mark dates if they are older than 5 days in perl? [migrated]

I know how to mark dates as YELLOW that are in the past: perl -MTime::Piece -pe ' BEGIN {$today = localtime->ymd." ".localtime->hms} @days = $_ =~ ...
5
votes
1answer
37 views

Count duplicate rows with constraint

I have the following file: A B 1990 A C 2001 A C 2013 A B 2001 B C 2013 A D 2001 A D 2014 I need to count duplicate pairs (in the 1st and 2nd column) and to each such pair assign the lowest value ...
4
votes
2answers
67 views

Get the maximum sum for a file on 2 keys

I have a file as below. key1 key2 key3 a1 2 l1 a1 2.5 l2 a2 2 l2 a3 2.5 l3 a3 2.1 l4 a3 2.2 l5 I am trying to find the maximum possible sum of key2 that satisfies the ...
0
votes
0answers
42 views

zip command is failing during high memory usage

We have several perl scripts, which generates and emails reports. The script that emails the files expects a .zip extension. The report scripts generates a .txt or .xls file and then runs the ...
3
votes
4answers
87 views

How to sort with a delimiter that is several characters long?

INPUT: $ cat a.txt 1FOO2FOO3 4FOO5FOO5 2FOO1FOO9 $ OUTPUT: $ cat a.txt | sort SOMEMAGIC 2FOO1FOO9 1FOO2FOO3 4FOO5FOO5 $ Question: How can I sort, if I have a several character long ...
0
votes
0answers
39 views

Install application on barebone linux board without internet

I'm kind of new to using linux for hardware development. I made a C program which uses ExifTool, and it works fine on the desktop. The ExifTool have to be installed and runs on Perl. I can cross ...
2
votes
1answer
116 views

Convert xml subtitle file to srt format

I have a xml subtitle that looks like this: <?xml version="1.0" encoding="utf-8" ?><transcript> <Item from="1.16" duration="4.68"><![CDATA[(Dong-hyuk is coming to see you now.) ...
1
vote
1answer
40 views

Retrieving fasta sequences using bed file information from locally installed file

I have a .bed file containing around 30000 rows for which I have the sequences retrieved using fetch-sequences module of the rsat tool (http://rsat.ulb.ac.be/rsat/help.fetch-sequences.html#usage). ...
3
votes
3answers
207 views

calculate sum of squares using shell script in perl/awk

I have 2 files as below. file1 0.34 0.27 0.32 file2 0.15 0.21 0.15 Now, I would like to calculate the sum of squares between each column. For example, [(0.34 - 0.15)^2 + (0.27 - 0.21)^2 + ...
3
votes
3answers
85 views

What perl script will scp directory with spaces in name?

I"ve been trying for several hours to figure out how to get perl to scp a directory with a space in the name. I'm currently getting the error scp: ambiguous target Here is the script that is not ...
-4
votes
0answers
27 views

pattern required perl scrip [duplicate]

Current pattern is as below: VMG110 836-16 836-18 836-19 336-20 836-23 MGW: VMG120 3802-1 3802-2 3802-3 3456-1 3456-4 Required output is: VMG110:836-16&-18&&-20&-23 ...
4
votes
2answers
57 views

Verify line endings from a text created by perl script

I am interested in seeing the contents of a text file in hex mode. I have tried :%!xxd and the problem is that I can not really understand which hex code represents each letter e.g. when you use an ...
4
votes
1answer
100 views

Is building Perl an inside joke or is it supposed to require this many `make` invocations?

So I am building Perl version 5.18.2 from source on an ARMv7 processor right now, a Krait on the Snapdragon S4, and I am not too sure how much support there is for such an architecture. By the way, I ...
1
vote
2answers
54 views

Receiving emails over IMAP and parsing with a script with minimal delay

I have a Perl script that uses NET::IMAPClient and MIME::Parser which simply reads new emails from an IMAP server and saves any attachments to disk. My question is: what is the best way to run this ...
1
vote
0answers
32 views

Some errors have occured when I installed lucene, a perl module!

Some errors have occured when I installed lucene, a perl module: [xlwang@localhost Lucene-0.18]$ make test Running Mkbootstrap for Lucene () chmod 644 Lucene.bs PERL_DL_NONLAZY=1 ...
9
votes
6answers
344 views

Using Perl to count the number of scientific numbers in a file

How I can count the number of scientific numbers in a file? The file also has a few lines of header which needs to be skipped. A portion of the file's content is in below. FileHeaderLine1 ...
1
vote
1answer
46 views

Extract time stamps and find the difference

I have a large set of logs as shown below: June 5 15:51:56.606 [3997]: TR#153. State machine - state = CC_STATE_IDLE, event = EVT_ISDN_SETUP June 5 15:51:56.607 [3997]: TR#153): SC ...
1
vote
2answers
37 views

Reformatting a LaTeX document by perl

I have a LaTeX document in which the modifications in the text and equations are done in red color in order for them to be distinguished from unmodified text: {\color{red} MODIFIED TEXT OR EQUATION ...
2
votes
2answers
57 views

How to print top five highest numbers from a column?

I have a text file with four columns. I need to read till end of file and print the highest number from column3 (top 5 values) along with column 1. input.txt xm|340034177|ref|RT_235820.1| 139697 ...
3
votes
5answers
122 views

Get values block by block in same file

I have a file say "SAMPLE.txt" with following content, P1 10,9:6/123456 P2 blah blah P1 10,9:5/98765 P2 blah blah P1 blah blah P2 I want a output file say "RESULT.txt" as, Value1:123456 ...
1
vote
3answers
291 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
3answers
20 views

To bold one line with Perl regex

I have 1. Lorem He he he % not sure spelling 2. Lorem ipsun I want to have \textbf{1. Lorem} He he he % not sure spelling \textbf{2. Lorem} ipsun My pseudocode attempt perl -000pe ...
2
votes
3answers
99 views

Apply item replacement inside enumerate in Perl regex?

Data 7. Masi is the same as \begin{enumerate} A B ABC ha lorem \end{enumerate} 1. ABC is \begin{enumerate} P B Lorem maam \end{enumerate} which I want to be 7. Masi is the same as ...
1
vote
4answers
61 views

Remove only given strings from given column?

INPUT: <tr><td>FOOBAAR</td><td>FOOO</td><td>BAAR</td><td><font style=BACKGROUND-COLOR:red>2014-02-14 ...
1
vote
1answer
52 views

Using kornshell or Perl to circumvent permissions needed by root

I have a problem where I need to change the ownership and permissions of one file that exists on more than 200 servers. I belong to 2 different groups and need to change the ownership from one group ...
1
vote
1answer
125 views

Perl print the lines matching with the columns of file 1 and file2

Here I am printing the contents of the file which are not matching. I want to do a vice versa, i.e. print the lines of file1 (those which are matching in file2) #!/usr/bin/perl # create names ...
0
votes
3answers
260 views

compare two files based on a column and print it

I have two big files of 400,000 lines. I want to compare the column 1 of the second file with column 1 of first file recursively. If they match I would like to print the whole line. It is a sorted ...
0
votes
2answers
80 views

How to match date in Perl — assuming UNIX regex is the same as Perl's

I want to match dates of the form Monday May 26 My attempt to do this is the following: /(.*day Jan.*|Feb.*|Mar.*|Apr.*|May|Jun.*|Jul.*|Aug.*|Sep.*|Oct.*|Nov.*|Dec.* [1-31])/ The regex form in ...
4
votes
2answers
60 views

Using perl to modify a LaTeX document

I am trying to use perl in order to modify a LaTeX document. In fact, I am trying to change the citation format from for example: . \cite{poelma20113d} to \cite{poelma20113d}. In other words, I ...
3
votes
1answer
128 views

Interpret an interpolated variable as a literal string in Perl regex

I am using perl to colorize a matched string MATCH=aaa printf "aaa\n/dev/aaa\nccc\n" | perl -pe "s/($MATCH)/\e[1;31m\1\e[0m/g" This works well until I try to match a string containing special ...
2
votes
3answers
148 views

replace column of a csv file with column from another file

I have two sample files like this: $ cat file1 abc,sachin cat,kumar $ cat file2 xyz pressure $ cat file3 xyz,sachin pressure, kumar I want the first column of file1 to be replaced with file2. ...
2
votes
0answers
57 views

How to print the first three lines and last two lines of a file using perl?

Through the command line I draw one or several of the patterns found text.xml file: perl -ln0e 'while(/<PMResult.*?<\/PMResult>/gs) { $x=$&;print $x if $x=~/BCCEL-[1-3]/}' text.xml I ...
0
votes
1answer
83 views

Duplicate specific text in text file, using perl or grep

I need to duplicate part of a plain text file as follows: The text file consists of a sequence of "pages", of the form: <page [lots of lines of text] /page> <page [lots of ...
0
votes
4answers
64 views

Print text between tags (inclusive) if certain text is found

I've got a task to extract data from several Apache servers. The task is to print out: <Directory ...> ... </Directory> where +ExecCGI is located within. Let me give an example to ...
-1
votes
1answer
114 views

Is Perl obsolete? [closed]

Is it worth learning Perl or it is an obsolete language and other languages should be learned instead of it? I am a newbie and I would appreciate it if someone could shed light on this subject and ...
3
votes
7answers
501 views

Finding the maximum of the values in a file

I have a file which contains several numbers, as follows. 21 12 33 35 21 12 33 44 52 63 14 12 23 34 11 12 13 53 1 12 43 33 44 How can I find the maximum of these values, which is 63? I wanted to ...
1
vote
1answer
266 views

Using EXIFTool to add EXIF data from filenames

There is a set of photos with timestamps in their filenames like these: Photo on 3-09-12 at 9.24 PM #2.jpg Photo on 3-09-12 at 9.24 PM #1.jpg Photo on 3-09-12 at 8.23 PM.jpg etc. ("3-09-12", ...
2
votes
4answers
71 views

Take a sum based upon particular columns

I am having a huge pile of data around 30 to 40 Million data. We need to process these files and send to another interface team. Below is my file format which we recevie c1 c2 c3 c4 c5 c6 A B ...
0
votes
2answers
56 views

Method to paste specific column when in terminal

I'd like to paste only the third column of data from within the terminal. I originally have something like: 4 SF0086 SF0086 12 SF0087 SF0087 17 TSF141 TSF141 29 TSF070 TSF070 30 TSF028 TSF028 31 ...
6
votes
3answers
513 views

Is there a perl or awk solution for this problem?

I have an input file (input.txt) like below. id1 id2 name weight 53723848 12651711 timburnes 1.36667 53530214 12651711 timburnes 1.51191 53723848 53530214 timburnes 1.94 764157 ...
4
votes
7answers
321 views

How can I groups numbers in a file

I have a file with numbers in float format. I can review them via sort -rn numbers.txt | less I would like though to be able to "group" them. I.e. easily see how many are in the same range. To give an ...
6
votes
3answers
165 views

What is the difference between invoking a perl script via sh or perl

I have a simple Hello World perl script. #!/usr/bin/perl print 'Hello world.'; It works fine if I run it via perl <file_name>, but it fails I run it via sh <file_name>. My ...
1
vote
3answers
73 views

Are there any difference using pipes?

Using Ubuntu 12.04. Using pipes (5 times): $ time echo XYZ | sed 's/X/A/g' | sed 's/Y/B/g' | sed 's/Z/C/g' ABC real 0m0.005s user 0m0.000s sys 0m0.000s $ time echo XYZ | sed 's/X/A/g' | sed ...