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

2
votes
2answers
158 views

ksh + delete number from string

the string IP include some IP address numbers as the following example echo ${IP[*]} 192.9.200.1 192.9.200.2 192.9.200.3 is it possible to remove some IP address number from the list ( using ksh ...
1
vote
2answers
331 views

perl one liner + how to match IP address that located in the first/sec field of file

the following perl one liner syntax verify if IP address in "$IP" match the IP ADDRESS in file perl -ne 'BEGIN{$IP=shift} print if /(^|\s)\Q$IP\E(\s|$)/;' $IP file file have two fields as the ...
2
votes
2answers
165 views

linux & solaris - separate netmask IP's from ordinary IP's

I have file with IP address and netmask IP's my target is to cut the netmask IP's from the file_with_IPs.txt and paste them to another file as file_with_only_netmask_ips.txt remark - netmask IP can ...
-3
votes
4answers
771 views

perl one liner + how to replace any last IP address octets

How to replace any last IP address octets (four octet ) to 0 remark: Implementation should be by Perl one linear on linux machines for example 192.9.200.124 will replaced to 192.9.200.0 ...
3
votes
2answers
307 views

No idea how to troubleshoot Bugzilla email issue

I'm a complete n00b when it comes to Bugzilla (and complex perl applications in general) so don't assume any level of knowledge in that area. If I haven't documented it in this post, assume I haven't ...
1
vote
2answers
423 views

Perl - /etc/shadow - Permission Denied

The following command is being executed by a non root user : perl -pi -e 's/^an24:/an24:\*LK*/g' /etc/shadow A permission denied is being issued. This indicates some privileges issues. Can such ...
-2
votes
1answer
243 views

Difference between command line argument and giving an input command [closed]

What is the difference between @ARGV and asking the user for input? $num = $ARGV[0]; and $_ = <STDIN>; Either way a user has to put an input isn't it? How are they different?
-4
votes
1answer
129 views

Usefulness of @ARGV in Perl [closed]

What is the difference between using just normal arrays and the special array (command line argument)? Normal array: @num(1,2,3,4), and you can use $num[0], etc Special array: you have to use @ARGV, ...
-2
votes
1answer
60 views

Perl confused with script [closed]

Write a perl script that takes one argument, the name of a file or directory. The script should call the stat function and print the resulting data along with a one line explanation of each field. my ...
-2
votes
1answer
77 views

Perl Script Explanation [closed]

#!/usr/bin/perl -w use strict; my $args; $args=@ARGV; if ($args<1) { die("Expecting a filename"); } sub showstat { print " $_[0] dev, device number of filesystem\n"; print " $_[1] ...
2
votes
3answers
1k views

I want to find duplicates in a file and add a character to the end of the line on the 1st match

I am trying to find duplicates in a file and once a match is found mark the 1st match with a character or word on the end of the line. eg my file (test.html) contains the following entries host= ...
-2
votes
1answer
103 views

Perl only one option at a time [closed]

There is a requirement where I can't put two options at the same time. For instance with -a option: file.pl -a file.text # executes file But if I write file.pl -a -a file.text # it is ...
3
votes
2answers
313 views

Passing quotes and full strings to bash -c or zsh -c

When I am in Perl and I call system(some_command), this invokes some_command on /bin/sh. I would like it instead to run some_command in another shell such as bash or zsh. One way of running ...
-3
votes
1answer
90 views

perl script explanation please [closed]

Write a perl program that reads in a text file containing one word per line. Create a hash containing the words read as keys and the number of times they have been read as the value. Print ...
2
votes
3answers
2k views

Easy way to parse syslog date format

I'd like to write a script that analyses the last week's syslog. But my syslog logs in a stupid date format, e.g. "May 22". If it logged as 2013-05-22, this task would be trivial. Is there a way ...
3
votes
3answers
179 views

sed + how to remove character/s that start or ended on each number

How do I remove the . character(s) that start in the beginning of each number or end on each number? Remark – perl one liner also good alternative for sed. Example input: .23.12.44.5. .233.3.3.3 ...
1
vote
1answer
209 views

Perl dependency issue

I've installed CentOS 6.3 (i386) recently. It has two perl binary /usr/bin/perl (v5.10.1) /usr/local/appx/perl/bin/perl (v5.8.8) My question: Is it possible to install some other funtinonality ...
6
votes
2answers
670 views

Special character '#' in Perl SSH command

I try to send command using SSH in my perl script with # but it gets truncated right at # Example: Input text is : $message = "Product ID # STK000134" The SSH command is : $execute=`ssh -q ...
6
votes
4answers
4k views

How to remove multiple blank lines from a file?

I have some text-files I use to take notes in - just plain text, usually just using cat >> file. Occasionally I use a blank line or two (just return - the new-line character) to specify a new ...
1
vote
2answers
57 views

Trimming one part if equal to another part?

I use an e-mail quote attribution string like this: On dd mmm yyyy hh:mm +hhmm, from info@example.org (Example Dot Org): where info@example.org is the sender's e-mail address and Example Dot Org is ...
0
votes
2answers
262 views

Reordering strings in linux

How can I change lines around using the command line? e.g. I have these lines: Acct-Status-Type = Start User-Name = "37XXXXXXX" Event-Timestamp = "Apr 12 2013 15:56:55 AMT" I need to ...
3
votes
3answers
2k views

Delete XML node containing certain element

I want to remove all Placemarks from a KML file that contain the element <tessellate>. The following block should be wholly removed: <Placemark> ...
0
votes
3answers
510 views

Sorting IP address according to the second field in file

in my ksh script I need to add the following task ( OS - linux/solaris ) I have the following file more test.txt /etc/backup/app 172.1.120 172.110.120 /etc/backup/app 172.1.120.12 ...
0
votes
1answer
112 views

read line by line and take a string in line and assign that string to the subsequent line using perl [duplicate]

Data file is fixed length file, and I want to read file line by line and take a string from the current line, and then append that string to the subsequent line and write into another file. For ...
-3
votes
1answer
159 views

How to transform two delimited ASCII files

These are 2 common delimited, text file transformation problems I'd like to find scripts to do (I dont know if awk or perl is best for these tasks). csh is the default shell on my Solaris10 unix ...
0
votes
3answers
110 views

Grep end regex matching

On OS X, system_profiler SPHardwareDataType outputs: Hardware Overview: Model Name: MacBook Pro Total Number of Cores: 4 L2 Cache (per Core): 256 KB L3 Cache: 8 MB Memory: 8 GB I want to ...
2
votes
3answers
329 views

awk, sed, grep, perl… which to print out in this case?

I have this syntax in a file (http response times from analog): <thead><tr><th class="x">seconds</th><th class="R">reqs</th><th ...
17
votes
2answers
10k 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+"$@"} ...
0
votes
2answers
105 views

perl one liner + print VALUE in the end of the line

The following perl one liner checks if $CURRENT_VERSION matches $NEW_VERSION exactly, and prints it if it does. Example: CURRENT_VERSION=223.3.12.4.5.3 NEW_VERSION=223.3.12.4.5.3 DATE=17.3.2013 ...
2
votes
1answer
254 views

perl + combine exec command with perl one liner line

I have the following short perl script rename.pl. How can I translate this script to one liner perl syntax? And how to combine the perl one liner in find command? rename.pl #!/usr/bin/perl $op = ...
0
votes
1answer
871 views

Rename files and directories with a special characters on solaris machines

The target of the following code ( commands ) is to rename files/directories and also support files/directories with a special characters as "@" or "." etc those commands are run fine on Linux ...
0
votes
2answers
156 views

Running something in a cron environment?

Cron executes whatever program is sent to it in such a fashion that anything written to STDERR causes either the kernel (or cron I'm unsure) to receive SIGPIPE. How does this functionality work? Is ...
1
vote
2answers
107 views

renaming a directory and its subdirs without affecting their files

I have to rename directories under the root directory with prefix "ms_PF" and then rename their subdirectories with the modified name of the main directory with an extra "_", and then copy all ...
1
vote
1answer
105 views

How do I reinstall the bioperl modules on Ubuntu?

I am trying to learn bioinformatics the hard way. I have no background in Linux, Ubuntu, bash, Perl, Python, etc. I'm trying to use several programs, mostly the bioperl modules, that have been ...
3
votes
1answer
791 views

Send log messages to a different location

I want to send messages from C program and from Perl script to a file (for example, /var/log/my_log). I don't have access to the syslog daemon configuration, so I think in launch a differente syslog ...
1
vote
1answer
131 views

Perl CPAN module download fails

The download for the 'App-xml_grep2-0.14.tar.gz' perl module continually fails for me. cpan http://search.cpan.org/CPAN/authors/id/M/MI/MIROD/App-xml_grep2-0.14.tar.gz Please login with USER and ...
0
votes
2answers
1k 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 ...
2
votes
1answer
95 views

How to list all present optical drivers?

How can I list all the installed optical drivers with udev or any other core-based tool (perl is also very good) ? P.S.: I know about the wodim --devices command, but it's an undesirable ...
0
votes
2answers
4k views

How to use the find command in Perl script?

Could someone tell me why the find command always go to the root directory but not the directory that is specified in $srceDir? my $srceDir = "/mnt/SDrive/SV/Capture Data/"; my $find_cmd = 'find ...
0
votes
1answer
120 views

Error trying to call find from perl

use warnings; use File::Find; my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/"; opendir(DIR, $srceDir) or die "Can't open $srceDir: $!"; my @files = (find -type f -newermt "12 Feb ...
2
votes
5answers
3k views

How can I split a text file into multiple text files using Perl?

I have a file ABC_TabDelim.txt that contains the following: 00:00:00:00 00:00:05:00 01SC_001.jpg 00:00:14:29 00:00:19:29 01SC_002.jpg 00:01:07:20 00:01:12:20 01SC_003.jpg 00:00:00:00 00:00:03:25 ...
1
vote
1answer
849 views

Identify text/ascii files in Linux/Solaris

I have a little project to build bash script that search in the OS ( Linux/Solaris ) the current IP address from files and replace them with other IP address. The problem is that IP address could be ...
1
vote
3answers
591 views

linux/solaris + verify duplicate valid IP address from file

what the best way to find duplicate IP from file ( I have ksh script in this script I need to write function that check for duplicate IP ) for example if IP - 192.1926.23.52 exists twice in file - ...
5
votes
2answers
243 views

Getting or cloning the users current terminal?

I have to work with a script that forks and launches an instance of xterm in order to display log output in one window and have an interactive interface in the other. Personally I prefer rxvt-unicode ...
2
votes
5answers
534 views

Replacing lines in files with file contents

I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like foo <?php include("file1.php"); ?> bar baz <?php ...
2
votes
2answers
86 views

'tie' [nonexisting] files to programs

Recently, I just had an idea which turned out to be pretty useful under certain circumstances. But first some simple explanation: In Perl, you have the option to tie variables to some functions ...
1
vote
2answers
110 views

No perldoc for POSIX?

On some other systems, like Ubuntu, perldoc POSIX works, but on Arch, %> perldoc POSIX No documentation found for "POSIX". %> perldoc /usr/lib/perl5/core_perl/POSIX.pm No documentation found ...
0
votes
1answer
1k views

Whats the most efficient way of adding milliseconds to this code?

#----------------------------------------------------------------------------- # # Get time string # #----------------------------------------------------------------------------- # sub formatTime ...
1
vote
1answer
635 views

Linux + replace STRING/WORD in file according to rule

My target is to replace any word/string/Any characters in file with new word/string according to the following rules: If numeric characters on the left side of word/string then we not replace the ...
3
votes
1answer
293 views

Use all system memory in Solaris

I am doing server testing and intentionally trying to crash a virtual Solaris server by using all memory. Server has a ulimit of 15 GB (several hundred GB of total system/swap memory). Is there a ...