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
3
votes
3answers
28 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
38 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
355 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
57 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
70 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
45 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
48 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
33 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
12 views

Is there an XS tutorial for Perl wrappers around C libraries? [closed]

I would like to fix bugs https://rt.cpan.org/Public/Bug/Display.html?id=75319 and https://perl5-porters.perl.narkive.com/sxHKGSuo/perl-32274-incorrect-path-from-file-spec-rel2abs-in-os-2 in Perl::...
0
votes
0answers
17 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
38 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
54 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
29 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
75 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
44 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
68 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
33 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
42 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
61 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
109 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
26 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
54 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
26 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
37 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
67 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 ...
-1
votes
4answers
60 views

Compare 2 Files and Display Matched records

I really need your help Guys, I am new here in Unix. I want to compare my File2(3 column) to my File1(raw data), and save the result in a new file. But my files have a different delimiter. Example: ...
2
votes
2answers
139 views

Templated read (like scanf)

I've got a shell script variable, which currently is defined like this: tsource=/backup/%HOST%/%SHARE%/%PERIOD% I want to match this template to another variable, which might have a value like this: ...
0
votes
2answers
37 views

Returning wrong results in perl script [duplicate]

I am running this command on linux shell it works smoothly sed -i 's/\[-.*-]//g' error .txt What it does is it removes patterns like [-any text-] along with the brackets and - sign. but when I try ...
0
votes
3answers
88 views

perl regex - How to match foobar that does not begin with (\s*//\s*)

Basically I want to find foobar on uncommented lines like: // foobar # do not match me foobar # match me otherfoobar # do not match me To match the commented lines I use this: ^(\s*//...
0
votes
1answer
43 views

Getting Error with system() in perl

' Number found where operator expected at ./scripttemp.perl line 5, near ""sed -i -r "4" (Missing operator before 4?) String found where operator expected at ./scripttemp.perl line 5, near "}" ...
1
vote
2answers
70 views

How to merge lines (of a multi-line code routine)

I have a file; contents are as follows: cat -n /tmp/my_file 1 verify(abc) { 2 foo : bar; 3 sub1(aa) { 4 line1; 5 } 6 sub2 (bb) { 7 line1; 8 // this line is a comment ...
2
votes
2answers
88 views

Use sed command for particular lines

I have a text file on a Linux machine and I want to run 3 sed commands for the lines entered by the user using a perl script. I am doing this manually till now. The sed commands I have to use are : ...
0
votes
2answers
64 views

Linux command to delete this

I want to delete this kind a pattern in my text file [-.(D_)-]. I did with sed and awk but no results. basically i want to delete anything that comes between [- & -] along with these characters ...
1
vote
2answers
33 views

Bash Perl multiline match into variable

I am trying to extract 2 strings from a multiline text. postmsg="\033[0;37m Email Settings" This line finds some match at the beginning of the string and puts it in a variable inCol. inCol=$(perl -...
3
votes
3answers
400 views

How can I list the different hex characters between two files?

allHexChars.txt \x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\...
0
votes
2answers
86 views

How to randomly change the order of two columns simultaneously for 1000 times using simulation values?

I have a data looks like this: ID pheno 231 0.12 432 0.32 11 0.0003 134 0.33 2334 0.553 12 0.33 100 0.331 1008 ...
1
vote
2answers
113 views

RegEx for replacing capture group content using sed [closed]

Have inputs.conf files in multiple directories that needs to match and parse each stanza and modify the index= to index=secure. This are files type in inputs.conf and also do run the script to locate ...
0
votes
0answers
26 views

Bash-Perl Make Substitution and Return array (string & number of replacements/substitutions)

I have this code that makes substitutions in a file segment. The code should be left mostly unharmed except for this problem. I need to return back to bash, the number of replacements made by perl ...
0
votes
2answers
55 views

Perl Negative Lookbehind with variable length bypass maybe?

I have this simple code perl -we 'my $file= " # parameter=10 # parameter=10 # parameter=10 parameter=10 parameter=10 "; $file=~ s/((?<!# ))\s*parameter\s*=.*/parameter=replaced/g; ...
-2
votes
3answers
56 views

Perl multiline match for 'something' which starts without '#\s'

UPDATE: The REAL answer to this MULTILINE question was given here by Stephane https://unix.stackexchange.com/a/521560/354415 Alternatively go line by line with perl by Terdon below: https://unix....
6
votes
2answers
112 views

number headings

I need to convert whitespace to a tiered, numbered list and have found this elusive. This is the sort of thing I'm after: Input (visible): Project #1 Subproject Task ...
2
votes
1answer
44 views

Perl Script in Bash Here Document (does not output variable)?

How come the following perl code, mkdir("foo"); print "foo: $!\n"; mkdir("foo"); print "foo: $!\n"; Will output the following (in a directory without a foo) perl ./asdf.pl foo: foo: File exists ...
0
votes
0answers
19 views

How to create RPM for generic Perl module

I have a generic Perl module that will run on any release of Perl 5. I need to create an RPM for it that will install it into the vendor_perl subdirectory. I don't want to create different RPMs for ...
0
votes
2answers
57 views

How to remove repetition of the content of file by column?

I have a file containing the following content: WP_021815421.1 OG5_132922 deth|YP_182312 3 -07 42.35 81.7 WP_021815427.1 OG5_128110 rbal|NP_868155 1 -55 50.72 53.2 WP_012456834.1 ...
0
votes
2answers
43 views

compare two column of two different CSV file & merge the output

TABLE1.csv DATE, TIMESTAMP, ID, START TIME, END TIME, DURATION 2019-04-05, 13:57:19, 1607,13:06:42, 13:07:12, 00:00:30 2019-04-05, 13:58:00, 2327,13:57:26, 13:57:43, 00:00:17 2019-04-24, ...
0
votes
1answer
58 views

Calculate the time difference between two columns in time format hh:mm:ss

I want the time difference between column 5 & column 4 My Input: DATE TIMESTAMP ID START TIME END TIME 2019-04-05 13:57:19 1607 13:06:42 13:07:12 2019-04-05 13:58:00 2327 13:57:26 ...
0
votes
0answers
37 views

Why the distr instmodsh cannot list the installed distr/vendor_perl modules ?

We find such a phenomenon with the instmodsh, that is, it can only list the installed CPAN modules ?! So why it cannot list the installed distr/vendor_perl modules though itself belongs to a distr ...
0
votes
2answers
57 views

Why is my multi-line perl string replace adding a blank line?

I'm trying to replace multiple lines in a text file (an XML element with an unknown number of children) with the contents of a separate text file. I've managed to get the replace mostly working using ...