perl

Unable to merge coverage data using genhtml

Hi all: I'm using genhtml (in Windows under cygwin) to generate a unit test coverage report from 2 coverage data files. They are all coverage data from the same unit test source file. However, when I entered the following command: perl genhtml /home/administrator/coverage1.dat /home/administrator/coverage2.dat I got the following o...

How can I find the final URL after all redirections in Perl?

Lets say I have "http://www.ritzcarlton.com" and that redirects me to "http://www.ritzcarlton.com/en/Default.htm". Is there a way in Perl to find the end url after all the redirects? ...

What decides the order of keys when I print a Perl hash?

Hi, activePerl 5.8 based #!C:\Perl\bin\perl.exe use strict; use warnings; # declare a new hash my %some_hash; %some_hash = ("foo", 35, "bar", 12.4, 2.5, "hello", "wilma", 1.72e30, "betty", "bye\n"); my @any_array; @any_array = %some_hash; print %some_hash; print "\n"; print @any_array; print "\n"; print $any_array[0]; print "\...

How can I export an Oracle table to tab separated values?

I need to export a table in the database to a tab separated values file. I am using DBI on Perl and SQL*Plus. Does it support (DBI or SQL*Plus) exporting and importing to or from TSV files? I can write a code to do my need, But I would like to use a ready made solution if it is available. ...

stuck with understanding 2 for loops

i am using this site as a resource http://www.perlmonks.org/?node_id=573138 I am trying to understand about O notation and it gives two examples of searching two arrays for the same element. First example has O(n^2) as does the second, however the second has an enhancement to it so it runs quicker but still maintains the same O notation...

Control a perl script's CPU utilization?

I am doing a lot of file searching based on a criteria in multiple iterations from my Perl script and it seems to take up 100% of the CPU time. Is there a way to control my script CPU utilization? I read somewhere about putting empty sleep cycles in my script. But I am not sure how to do this. ...

In Perl, why do I need to @b = @{dclone(\@a)}? Why can't I just @b = dclone(\@a)?

I have an array of various things including scalars and arrays. I want to make a copy of it, and tried the following: @b = dclone(\@a) but then when I try to read one of the scalar values from b, I get nothing back. Everything appears to work when I copy it this way, though: @b = @{dclone(\@a)} What is the reason? ...

Why doesn't Perl's for() go through all of the elements in my array?

Have a perl brain-teaser: my @l = ('a', 'b', 'c'); for (@l) { my $n = 1; print shift @l while (@l and $n --> 0); print "\n"; } What's it print? Should be a, b, and c, right? But oh wait actually there's a bug somewhere, it only prints a and b. Probably just some stupid off-by-one, should be easy to solve, right? Ok so mak...

How can I access INI files from Perl?

What is the best way to parse INI file in Perl and convert it to hash? ...

How do I find a literal % with the LIKE-operator with DBD::CSV?

Hello! How do I find a literal % with the LIKE-operator? #!/usr/bin/perl use warnings; use strict; use DBI; my $table = 'formula'; my $dbh = DBI->connect ( "DBI:CSV:", undef, undef, { RaiseError => 1 } ); my $AoA = [ [ qw( id formula ) ], [ 1, 'a + b' ], [ 2, 'c - d' ], [ 3, 'e * f' ], [ 4, 'g / h...

How can I force list context in Template Toolkit with RDBO?

I have a TT plugin that does the trivial unique ids: sub get_unique_uid_tt { my ( $classname, $o ) = @_; my %h; foreach my $item ( @{$o} ) { unless ( exists $h{ $item->id } ) { $h{ $item->id } = 1; } } return keys %h; } where the template call is simply: [% Namespace.get_unique_uid_tt( data.users ) %] and...

How can I manually add activity to Bugzilla?

I am making a simple time sheet for which people can register times worked on a bug real quickly. But the hours added to the bugs_activity table are not noticed anywhere. here is a simple made up line Bugzilla::Bug::LogActivityEntry(1, 'work_time', 0, 66, 1, '2010-01-12 14:44:44'); Pretty much, add 66 hours to bug 1, work time...

How can I modify $0 value in Perl?

I want to test one of my Perl scripts. I want to modify the "$0" value during compile time. Is that possible? ...

How can I use 32-bit Perl to thaw something frozen with 64-bit Storable?

I'm trying to thaw a database BLOB that was frozen using Storable on a 64-bit Solaris (production) machine. When I try to thaw on a 32-bit Windows (development) PC I receive "Byte order is not compatible error". perl -v (on solaris) This is perl, v5.8.8 built for i86pc-solaris-64 perl -v (on Windows) This is perl, v5.10.1 built for MSW...

Why does XML::Twig output the extracted string twice?

Hi! Why do I get my string two times in the output? #!/usr/bin/perl use warnings; use strict; use XML::Twig; my $string = '<cd_catalogue><title>Hello, World!</title></cd_catalogue>'; my $t= XML::Twig->new( twig_handlers => { cd_catalogue => \&cd_catalogue, }, pretty_print => 'indented', ); $t->parse( $string ); s...

How can I convert a string to a float with Perl?

Is there any function like int() which can convert a string to float value? I'm currently using the following code: $input=int(substr($line,1,index($line,",")-1)); I need to convert the string returned by substr to float. ...

What is the recommended way to encrypt user passwords in a database?

In a web application written in Perl and using PostgreSQL the users have username and password. What would be the recommended way to store the passwords? Encrypting them using the crypt() function of Perl and a random salt? That would limit the useful length of passswords to 8 characters and will require fetching the stored password in ...

How can I improve Perl's performance with massive data?

Hi, I'm searching for improving my algorithm for an allocate massive data riddle. If anyone can think of some good idea that makes it run faster, I'll appreciate it. I have 8 files contains 2 parameters: 1) start point 2) end point These type of data repeat itself with different numbers along the file. means I could have a file with ...

How can I convince people to use proper object oriented Perl?

I have been using an Object-Oriented MVC architecture for a web project, and all the models are OO Perl. But I have noticed a couple on the team are reverting to procedural techniques and are essentially using "objects" as dumping grounds for related functions. Their functions basically read/write directly to/from the database. What's t...

What is a quick way to run a single script to automatically install missing modules using only Perl core?

I inherited a project which is supposed to be able to be deployed to other servers. This project has a number of simple module dependencies which however might not be present on all target machines. As such I'd like to be able to run a single command line script that checks which Perl modules are installed and tries to automatically ins...