perl

How to find all Keys in a hash have a value in Perl

How do you determine if all hash keys have some value ? ...

How can I add to beginning or end of a file in Perl?

What is the best way of writing the some content to the beginning and end of a File in Perl ...

Code Profiling Tools for Perl

I need to test Perl Application ( File operation , Data base operation..etc ) . I am looking for some profile tool for Perl code is there any tools for Perl Code Profling like gprof in Linux ...

Perl - Printing the next line

Hi, I am a noob Perl user trying to get my work done ASAP so I can go home on time today :) Basically I need to print the next line of blank lines in a text file. The following is what I have so far. It can locate blank lines perfectly fine. Now I just have to print the next line. open (FOUT, '>>result.txt'); die "File is not a...

Why isn't this simple Perl push/pop program working?

I'm reading the Llama (Learning Perl) book, and working on the exercises. And for this exercise: Write a program that reads a list of strings on separate lines until end-of-input and prints out the list in reverse order. [. . .] Well, I already figured out a simpler approach (I remembered you could use reverse on arrays... Perl is ...

What does this line from the fileno perldoc mean?

The perldoc for fileno says Filehandles connected to memory objects via new features of open may return undefined even though they are open. Is this referring to new style calls to open in general, or to the IO::Scalar style calls to open? ...

Randomizing pages in Wikipedia with MySQL and Perl?

I found a perl script that manages randomizing the wikipedia articles in Wikipedia here. The code seems to be slightly computer generated. Due to my present interest in MySQL, I thought you could possibly have the links and related data in a database. I know that MySQL is good in maintaining relations between tables, while it seems you ...

Is Perl's unpack() ever faster than substr()?

Several times I've read that unpack() is faster than substr(), especially as the number of substrings increases. However, this benchmark suggests otherwise. Is my benchmark flawed, or is the alleged performance advantage of unpack() a holdover from older versions of Perl? use strict; use warnings; use Benchmark; my ($data, $format_stri...

grep vs Perl. Should I mod this to work, or should I just replace it with Perl code?

I am writing something that will allow users to search through a log of theirs. Currently I have this, where $in{'SEARCH'} is the string they are searching. open(COMMAND, "grep \"$in{'SEARCH'}\" /home/$palace/palace/logs/$logfile | tail -n $NumLines |"); $f = <COMMAND>; if ($f) { print $Title; print "<div id=log>\n"; ...

Real-time intercepting of stdout from another process in Python

I'd like to run a system process, intercept the output, and modify it real-time, line by line, in a Python script. My best attempt, which waits for the process to complete before printing, is: #!/usr/bin/env python import subprocess cmd = "waitsome.py" proc = subprocess.Popen(cmd, shell=True, bufsize=256, stdout=subprocess.PIPE) for l...

SIGALRM while sleeping on Solaris 9

I'm running into a bit of a weird error while running Perl in a chroot environment on Solaris 9 (Sparc). We are using a custom Perl, but it's almost exactly Perl 5.8.7, and this version has been running for years on various platforms including Solaris 8-10. The following code is pretty straightforward: #!/usr/bin/perl use strict; use...

How can I replace all £ in a file with &pound; with Perl?

I am trying to replace all £ symbols in a HTML file with &pound;. My regular expression does not seem to work. Could you please help? ...

Problems with XML encoding in perl xml Lib

Replacing the Special Character using Perl while i am doing this . I got this error . I just try to merging the 2 xml file using XML::Lib. parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xA3 0x32 0x33 0x6B �23 to c�27 . What is the issue and how to resolve this this I thought before going to XML Parser , I...

Packaging Perl modules with Config files?

I am currently creating a Perl module for in house use. I used ExtUtils::ModuleMaker to generate a build script and skeleton for my Perl module. I would like to include .ini config files that my core modules need to run properly. Where do I put these files so they are installed with my module? What path do I need to use to access these c...

How do I color output text from Perl script on Windows?

I would like to color format the text printed to the console using the Perl print command. In my case the script will only be run under WinXP-DOS Command Line but it would be great if it was OS independent although I would rather tie it to WinXP than have to download a seperate package. ...

What is best module for parallel processing in Perl?

What is best module for parallel process in Perl? I have never done the parallel processing in Perl. What is good Perl module for parallel process which is going to used in DB access and mailing ? I have looked in module Parallel::ForkManager. Any idea appreciated. ...

Why can't I properly encode a boolean from PostgreSQL via JSON::XS via Perl?

I have a query on a PostgreSQL system returning a boolean: my $sth = $dbh->prepare("select 'f'::boolean"); $sth->execute; my @vals = $sth->fetchrow_array; According to the DBD::Pg docs, The current implementation of PostgreSQL returns 't' for true and 'f' for false. From the Perl point of view, this is a rather unfortunate ...

Is there a mod_perl2/Perl 5 equivalent to PHP's ignore_user_abort()?

I'm writing an internal service that needs to touch a mod_perl2 instance for a long-running-process. The job is fired from a HTTP POST, and them mod_perl handler picks it up and does the work. It could take a long time, and is ready to be handled asynchronously, so I was hoping I could terminate the HTTP connection while it is running....

Perl: Generating Arrays inside a Complex Hash

In the quest to make my data more accessible, I want to store my tabulated data in a complex hash. I am trying to grow a 'HoHoHoA' as the script loops over my data. As per the guidelines in 'perldsc': push @ { $hash{$column[$i]}{$date}{$hour} }, $data[$i]; The script compiles and runs without a problem, but doesn't not add any data to...

Why doesn't this Perl regex work?

I have a Perl script, that's supposed to match this string: Sometimes, he says "hey fred, what's up?" It says if it found fred at the beginning, end, or middle of the word, or if it just found "fred". So it matches Alfred, and Frederich. Well, in this string, it's supposed to say it found fred on its own, but it's saying it found it a...