perl

Why does my Perl script halt if CGI module is used after reading from stdin on Windows?

I'm trying to implement a progress indicator for file uploads. Part1 and Part2 of the script run properly if executed separately. But if executed together the script halts at: my $cg = new CGI(); The problem only occurs on an Windows server. What could be the reason? #!C:\Perl\bin\perl.exe -w use CGI; $post_data_filename = "C:\\t...

How do I print the '%' character with 'printf'?

Simple problem that I can't figure out... How can I print a '%' character within a printf string? The code below prints it, but gives an 'invalid conversion' error as well. printf "\t\t".$hour."00 HRS\t=>\t%.2f\t%.2f\t%.1f\%\n", $total, $max15, ($max15/$total*100); Should output something like: 0000 HRS => 3125.19 8...

How can I traverse a directory tree using a bash or Perl script?

I am interested into getting into bash scripting and would like to know how you can traverse a unix directory and log the path to the file you are currently looking at if it matches a regex criteria. It would go like this: Traverse a large unix directory path file/folder structure. If the current file's contents contained a string tha...

How can I run Perl test cases in Eclipse using EPIC?

I am using eclipse EPIC (Perl plug-in) to run my Perl scripts. The scripts are running fine. but I want group my scripts and run together at a go. How can I do this? The scripts I am running are test cases. So basically it would be nice if I can take the results of each script and display them in table like fashion or write into a file ...

In Perl, how can I write and read CSV file composed from a key and array?

I have a problem to write and read properly a CSV file composed of name(key) and array of values: testarray.csv foo1 ,0,0,0,0,1 foo2 ,1,0,0,0,1 foo3 ,3,4,5,6,7 . . . I need to represent that file as follows: foo# will be the key and the five following numbers will be its array. What is the simple way to conduct that and to recall i...

How can I create relative/approximate dates in Perl?

I'd like to know if there are any libraries (preferably DateTime-esque) that can take a normal date time and create an appropriate relative human readable date. Essentially the exact opposite of the more common question: How can I parse relative dates with Perl?. Obviously, the exact wording/interpretation is up to the actual implementa...

Is there any thing similar to HttpURLConnection in Perl?

I want to create an HTTPURLConnection to a PHP script and get the HTTP response returned by the script. Is there a way to do this in Perl? In short i want Perl equivalent to following: java.net.URL url = new java.net.URL(urlPath); java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection(...

How can I construct a family tree with Perl?

I have a programming assignment in Perl that requires me to do the following: Creates a table in a mySQL database, and inserts these records into it: Loads the data from the table into an array of instances of class Son. Using the array, creates HTML code representing a father-son tree, and prints the html code to STDOUT. It's not nece...

How can I convert OO Perl to Java?

I inherited large monolithic body of OO Perl code that needs to be gradually converted to Java (per client request). I know both languages but am rusty on my Perl skills. Are there any tools (Eclipse plugins?) that you folks can recommend to ease the pain? ...

Is it possible to send a SIP notify message programmatically to a registered SIP device ?

Hello, Is it possible to create and send a SIP packets programmatically to a registered SIP device ? I would like to send a SIP notify message, something like shown below: NOTIFY sip:[email protected] SIP/2.0 To: <sip:[email protected]>;tag=78923 From: <sip:[email protected]>;tag=4442 Date: Mon, 10 J...

How to store an IP in mySQL

strong textWe've got a healthy debate going on in the office this week. We're creating a Db to store proxy information, for the most part we have the schema worked out except for how we should store IPs. One camp wants to use 4 smallints, one for each octet and the other wants to use a 1 big int,INET_ATON. These tables are going to be h...

What does a while after a print mean in Perl?

I am new to Perl. Know a little bit of C though. I came across this snippet in one of our classroom notes : $STUFF="c:/scripts/stuff.txt"; open STUFF or die "Cannot open $STUFF for read :$!"; print "Line $. is : $_" while (<STUFF>); Why is the while after the print statement? What does it do? ...

How can I find the number of keys in a hash in Perl?

How do I find the number of keys in a Perl hash variable, like Perl array $#? ...

Why do the '<' and 'lt' operators return different results in Perl?

I am just learning Perl's comparison operators. I tried the below code :- $foo=291; $bar=30; if ($foo < $bar) { print "$foo is less than $bar (first)\n"; } if ($foo lt $bar) { print "$foo is less than $bar (second)\n"; } The output is 291 is less than 30 (second). Does this mean the lt operator always converts th...

How can I access the last Perl hash key without using a temporary array?

How can I access the last element of keys in a hash without having to create a temporary array? I know that hashes are unordered. However, there are applications (like mine), in which my keys can be ordered using a simple sort call on the hash keys. Hope I've explained why I wanted this. The barney/elmo example is a bad choice, I admit,...

How can I programmatically convert Word doc or docx files into text files?

I need a way to convert .doc or .docx extensions to .txt without installing anything. I also don't want to have to manually open Word to do this obviously. As long as it's running on auto. I was thinking that either Perl or VBA could do the trick, but I can't find anything online for either. Any suggestions? ...

Why don't my system calls work in the Perl program I wrap with pp?

I have a Perl/POE/Tk script running on Win32 ActivePerl that calls executables using system. I created an exe of the script using pp. I can unpack the exe and see the executables off the root of the "zip" file directory, but when I run the exe and try to use the functionality of the system calls I get a "file not found" type of error; '...

How do I remove unwanted values from the begining of an array in Perl?

I am storing values in an array using the push function. The first value in array is being stored at 4 element instead of first element. For instance, after storing values when I print first element $array[1] it prints space/nothing but when I print the fourth element $array[4] it prints the first value. Any suggestions on how to remove ...

How can I extract the values after = in my string with Perl?

I have a string like this field1=1 field2=2 field3=abc I want to ouput this as 2,1,abc Any ideas as to how I can go about this? I can write a small C or Java program to do this, trying I'm trying to find out a simple way to do it in Perl. ...

Why doesn't a * in my pipe open in Perl work on Windows?

I am having this strange issue with Perl. I am trying to execute an external program from inside my Perl script and this external program takes string + wildcard as parameters. My Perl program looks like this my $cmd_to_run = 'find-something-in-somedb myname* |' open(procHandle, $cmd_to_run); # I am using open because I want to ...