perl

Tie::IxHash ordered associative arrays in Hash of Hashes ?

Hi, How can I preserve the order in which the hash elements were added FOR THE SECOND VAR ? ( Hash of Hashes ) For example: use Tie::IxHash; my %hash; tie %hash, "Tie::IxHash"; for my $num (0 .. 5){ $hash{"FirstVal$num"}++; } for my $num (0 .. 5){ $hash{"FirstValFIXED"}{"SecondVal$num"}++; } print Dumper(%hash); When dum...

How can I change parameter value in XML using Perl ?

My XML file looks like this: <Configuration> <Parameters> <Component Name="Aas"> <Group Name="PrivilegesMapping"> <Parameter Name="PrivilegesLoaderInterval"> <Description> The interval (in minute) </Description> <Type...

How do I install Devel::Cover on ActivePerl 5.8.7?

cpan fails with this weird error as follows Error: Unable to locate installed Perl libraries or Perl source code. It is recommended that you install perl in a standard location before building extensions. Some precompiled versions of perl do not contain these header files, so you cannot build extensions. In such a case, please build a...

How to determine connection state of Perl DBI database handler

How to determine connection state of Perl DBI database handler(is connection opend)? Something like .NET SqlConnection.State == Open. May be something like defined($dbh->do("some nop sql")) but can't find sql nop statement to use. ...

$cmd output in to a file

I have this below code: $cmd = system ("p4 change -o 3456789"); I want to print the output -description of the change list - into a file. $cmd = system ("p4 change -o 3456789 > output_cl.txt"); will write the output in to output_cl.txt file. But, is there anyway to get the output through $cmd? open(OUTPUT, ">$output_cl.txt")...

how do i replace this text in a file from the command line in linux?

hi! i have a proxy config file which has the following line: Allow 212.21.3.44 i'd like to replace that ip address portion with my new ip address when it changes. it would probably be easier to just use the line number when searching for it - i don't think that config file will change at all other than that particular setting. how c...

Download only new/modified files with perl (or wget)

I have a Perl script which downloads a large number of files from a remote server. I'd like to avoid hammering the server, so I'd like to avoid downloading a file if it hasn't been modified since my last check. Is there a good way to do this, either in Perl or with a shell script? Can I get the server to send HTTP 304 rather than HTTP ...

Date Manipulation in Perl

Hi All, I had a problem with date manipulation.This is my scenario.I have a daily generating report files,they will be generated from Monday to Friday.Now I need to compare those reports.My perl code should work in such a way that if today is Monday I need to compare todays report with previous week Friday's report.And my date format...

Search engine for CPAN modules

I find the extensive volume of modules available through CPAN to be somewhat at odds with its search capacities. I'm aware that there is a lot of data stored about modules, including the dlsip tags. However I'm not aware of a convenient interface to query this database. search.cpan.org seems to provide only a basic textual search, and...

What are the strengths/weaknesses of ShipIt vs Dist::Zilla?

I started using Dist::Zilla several months ago. However, at YAPC::NA someone mentioned that they use ShipIt instead. Then today I noticed a .shipit file in miyagawa's cpanminus directory on github, so I decided to look into it some more... My initial impression is that ShipIt has a subset of what is available with Dist::Zilla, but I don...

Using Perl's Tk debugger, how can I set a breakpoint in my Perl library?

I have a large Perl script that is broken into several Perl libraries. In the Perl Tk debugger, I'd like to be able to set a breakpoint in one of the library files. The only way I know how to set a breakpoint in ptkdb is to navigate to the line in the source code pane. However, that source code pane only has the top level Perl script....

How do I decode a CGI form?

How do I decode a CGI form in Perl? ...

Parsedate question in Perl

In Perl, why I get different results from parsedate(2010-7-2 13:0:0) and parsedate(2010-7-2 13:00:0) ? ...

Hex dump parsing in perl

I have a hex dump of a message in a file which i want to get it in an array so i can perform the decoding logic on it. I was wondering if that was a easier way to parse a message which looks like this. 37 39 30 35 32 34 35 34 3B 32 31 36 39 33 34 35 3B 32 31 36 39 33 34 36 00 00 01 08 40 00 00 15 6C 71 34 34 73 69 6D 31 5F 33 30 ...

Mapping of name to the filename in perl

i am confused now... Here is my problem: I have a text file in this format Tom //name Washington account.txt //filename Gary //NAME New York accountbalance.png //filename Mary //name New Jersey Michelle //NAME Larry //NAME...

Why am I getting an Internal Server error while using Mechanize to do the file fetching?

I'm having trouble downloading an mp4 file using WWW::Mechanize. A normal browser, like Firefox, can do the file fetching without any problem with or without Javascript enabled. So it seems to me Javascript, the usual suspect, hasn't played a real part in my problem. I've also added in my script the same headers as sent by Firefox to the...

How do I obtain the current URL in Perl?

What's the Perl equivalent for the following PHP calls? $_SERVER["HTTP_HOST"] $_SERVER["REQUEST_URI"] Any help would be much appreciated. ...

Any simple tool to simulate server load?

I have an IIS server to test for load. But I don't need the tool to give me any performance data. I only want a simple tool/script that would flood my server with requests. I know about wcat, Jmeter, httperf etc. but those have too many extra features. I don't want all that functionality. Just a simple script would do that would send, ...

How do I map a database name to a server name from a data file using a hash?

#!usr/bin/perl use strict; use warnings; my $file_name = "rem.txt"; open(FILE, $file_name); while (<FILE>) { my $line = $_; if ($line =~ m/(\w*Svr)\b/) { my $server_name; $server_name = $1; my @arr_servername = $server_name; print "@arr_servername\n"; #print "$server_name\n"; } elsif ($...

Perl equivalent of PHP's get_file_contents() ?

The following PHP code does exactly what I want to do. The problem is I need to re-create it in Perl and I've been playing around with the open() and sysopen() Perl functions but can't do it. Does anyone have any help or know of any links that might help? Thanks. $URL = "http://example.com/api.php?arguments=values"; echo file_get_conten...