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
1answer
151 views

How to get the filename if particular regexp is present in the file in Perl

In a directory containing many files, if a particular regexp (or format) was found in file, I'd like to get that filename Example: If the word "rama" is found in file called ramayana, print the ...
2
votes
1answer
936 views

Escaping of meta characters in basic/extended posix regex strings in grep

Is it possible to escape all meta characters of a string inside a variable before passing it to grep? I know similar question has been asked before on SE (here) and also a good explanation here, but I ...
1
vote
1answer
2k views

Apache cannot fork: cannot allocate memory

I am running apache on Fedora with mod_perl. The server forks a process to send an email frequently - and the fork exits. Suddenly, I got: Cannot fork: Cannot allocate memory. There was plenty of ...
4
votes
2answers
798 views

Parsing XML from a shell script

I have a datafile like this: <Key name="com.ahsay.afc.cpf.UserGroup" content="" allowMultiple="Y"> <Value name="rsv-id" inheritParentAttribute="Y" type="string" data="1328200856753" ...
0
votes
3answers
356 views

Prevent init daemon echoing on TTY

Below is an init script which starts/stops a daemon. The daemon is unfortunately printing the parsed packet data (from /home/nuthan/program/server), a socket server written in perl, listening to a ...
0
votes
1answer
783 views

Manually assign a value when inet_ntoa does return an ip address

Code: foreach $hostname (@hostnameUniqueSorted){ $ipaddr = inet_ntoa((gethostbyname($hostname))[4]); if(chomp($ipaddr) =~ '^$') $ipaddr == "ip not avail"; <-- doesn't work } If the ...
2
votes
4answers
1k views

Extract IP address from a string

The Linux host command returns: hostA.domain.com has address xx.xxx.xxx.xx How do I get just the IP address and put it in the $ipaddr variable? open(FILE, "hostlist.txt") or die("Unable to open ...
2
votes
2answers
514 views

how to apply this patch

There is a patch fix for perl module net::ssh2 it fixes a seg fault error that happens on some machines. It's located here: https://rt.cpan.org/Public/Bug/Display.html?id=36614 I downloaded the ...
1
vote
0answers
91 views

Perl Script to Display Pork Offline Message

I use pork 0.99.8.1 on openSuse 11.4 for my AIM account when I don't want to use irssi + bitlbee. The only problem I have encountered so far is that offline messages are not displayed. I just get a ...
8
votes
6answers
1k views

Delete lines beginning with #

How do I delete lines beginning with a #, given that there can be whitespace on the left and right of the #? # Master socket provides access to userdb information. It's typically
5
votes
3answers
970 views

Regex & Sed/Perl: Match word that ISN'T preceded by another word

I'd like to use sed or perl to replace all occurrences of a word that doesn't have a certain word in front of it. For example, I have a text file that contains a plot of a movie and I want to replace ...
2
votes
1answer
438 views

How to insert a first column to many files + how to convert unix time to normal time

There are many-many files in a directory that has e.x.: the following content: INPUT: root 1324711901 sshd 1272725792 And I'm searching for a solution how to convert the content of the ...
0
votes
2answers
418 views

Need to install MySQL Client libaries but RPM not installing them

I'm trying install the MySQL Client libraries for the Perl Mod of the same name but when I run sudo rpm --install -v --allfiles MySQL-client-5.5.16-1.linux2.6.i386.rpm and querying the rpm ...
2
votes
2answers
246 views

perl regex replacing globally when global not selected

I'm using Ubuntu 11.04 and wrote a small script that searches within text files for certain "tokens" and replaces with some a prewritten snippet from a template file of the same name. The text files ...
3
votes
3answers
185 views

What does . match?

In working with regular expressions, I have been told that a dot character . will match everything. Except for newlines \n. Are there any other exceptions? What about the NUL character \0, or the ...
4
votes
2answers
932 views

How do you determine if AIX 5.3 has PERL installed?

Simply put, how do you determine if AIX 5.3 has PERL installed as non-root?
4
votes
1answer
760 views

Renaming files to have lower case extensions with 'rename'

I'm trying to currently rename a large set of files and have been using quite kludgy methods to do so, such as: rename 's:(.*)\.MOV:$1.mov:g' *.MOV rename 's:(.*)\.JPG:$1.jpg:g' *.JPG What I'd ...
4
votes
4answers
852 views

How can I remove a specific string from a file only if there are other lines in the file?

How can I remove a specific string from a file ONLY if there are other lines in the file? For example, don't touch this file: cat file.txt ASDF but remove "ASDF" from this file: cat file.txt ASDF ...
4
votes
3answers
3k views

How to filter IPv4 and IPv6 addresses?

echo "1.1.1.1" | awk '/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/ {print $1}' How can I filter IPv4 addresses in a script, and how can I filter IPv6 addresses. I mean more precisely then this so the oneliner ...
2
votes
1answer
256 views

How race conditions affect reads and writes (that happen at the same time)

Let's say I open a file a for reading. What if an application, let's call it aWriter writes to this file in random intervals. Are there any possibilities of me receiving improper file contents if I ...
1
vote
1answer
391 views

How can I get mod_perl running in Arch Linux?

I've installed mod_perl, and even tried enabling it, unfortunately it seems to be preventing apache from starting. LoadModule perl_module modules/mod_perl.so here's the error. /usr/sbin/apachectl: ...
1
vote
4answers
3k views

ncurses based menus

How can I build an ncurses based menu? Are there any other solutions for building "menus" for use on the console? I just need an "inter-operating system" (all non-windows :P) solution. Are there any ...
4
votes
1answer
249 views

Passing clicked links in rxvt to a script

I start my browser vimprobable in tabbed like so: "`tabbed -d > /tmp/tabbed.xid`; vimprobable2 -e `cat /tmp/tabbed.xid`" [1] I am then able to send all new instances of vimprobable to tabbed (and ...
2
votes
1answer
388 views

How do I make a droplet/.app in platypus for my unix command?

This is my sample code from the platypus tutorial. I am trying to make it work with a command named pymol, and I want it to open .pdb files or open just pymol. I know nothing about perl, but I have ...
1
vote
1answer
408 views

Need command-line program to download all of http:// https:// scp:// ftp:// style links (on e.g. ubuntu)

I'm writing a perl program where I want to accept all kinds of "file names" from the user, including /home/foo/bar.txt and scp://server/some/file.txt or whatever. And then I thought that if I can find ...
1
vote
1answer
612 views

Find server with small ping latency (my script, but can anyone write it in e.g.: Perl?) [closed]

I want to download OpenBSD with FTP with a script, and I want to download it from a server that is near me. So I want to choose a mirror that has low "ping latency". I wrote a little script, that ...
1
vote
1answer
464 views

How to convert <a href=“http://xy.com”>XY</a> to [http://xy.com XY]?

Just for editing Wiki's.. So i have this input [from a larget text]: TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA TEXT TEXT <a ...
3
votes
4answers
1k views

Replacing text from a list of replacements. Added complication: backslashes

I have a file A that contains pairs of strings, one per line: \old1 \new1 \old2 \new2 ..... I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
7
votes
6answers
2k views

Is there any alternative to grep's -A -B -C switches (to print few lines before and after )?

grep -A 2 -B 3 prints 2 lines after the grep string and prints 3 lines before. grep -C 3 prints 3 Lines before and 3 lines after Unfortunately, the grep I'm using does not support these ...
7
votes
1answer
309 views

Is there a way to make perl -i not clobber symlinks?

A friend of mine points out that if you do: perl -pi.bak -e 's/foo/bar/' somefile when "somefile" is actually a symlink, perl does just what the docs say it will do: It does this by renaming ...
1
vote
2answers
256 views

Perl find and replace is writing every file

Here's the test script I'm running matt@server:~ $ cat test.sh #!/bin/bash mkdir test cd test echo "has the string foo" > yes.txt echo "hasn't the string" > no.txt ls -l --time-style=full-iso ...
4
votes
3answers
2k views

Help with piped program in sendmail's /etc/aliases

I'm trying some sort of auto-subscription via a homegrown script. I know it can be achieved by mailing lists such as Mailman but I also want to learn at the same time on how to do it by hand. Here's ...
3
votes
1answer
900 views

Query DHCP server leases from Perl script

I have a Windows 2003 server and need to poll the DHCP lease information from it with a perl script that is running on a Ubuntu server. Then I need to analyze & store the information in a mysql ...
1
vote
0answers
717 views

Which scripting language is most widespread in system administration tasks? [closed]

I am migrating to Linux and have some experience with the Mac OS X command line/bash. I'd like to automate system admin tasks via scripting, but I am unsure as which language is the most used in the ...
6
votes
3answers
5k views

How can I install perldoc on Ubuntu?

Ubuntu 10.10 comes with Perl 5.10.1 pre-installed, but strangely enough perldoc isn't part of the package. $ perldoc You need to install the perl-doc package to use this program. How can I make ...
1
vote
4answers
1k views

Using regex to see if a UNIX process is up

In UNIX, I am checking to see if a process is up by executing the following command; E.g. psg dtllst pe99 This returns the following output if the process is running; UID PID PPID C ...
5
votes
1answer
3k views

Execute Nohup command with input

In UNIX, I have a process that I want to run using nohup. However this process will at some point wait at a prompt where I have to enter yes or no for it to continue. So far, in UNIX I have been doing ...