perl

Cannot install XML::LibXML module on Windows

I am trying to use XPath to extract some HTML tags and data and for that I need to use XML::LibXML module. I tried installing it from CPAN shell but it doesn't install. I followed the instructions from CPAN site about the installation, that we need to install libxml2, iconv and zlib wrappers before installing XML::LibXML and it didn't ...

Convert CSS Style Attributes to HTML Attributes using Perl

Real quick background : We have a PDFMaker (HTMLDoc) that converts html into a pdf. HTMLDoc doesn't consistently pick up the styles that we need from the html that is provided to us by the client. Thus I'm trying to convert things such as style="width:80px;height:90px;" to height=80 width=90. My attempt so far has revealed my limited un...

Why do I get an error from XML::SAX::PurePerl::EncodingDetect although I did not load that module?

Hi, Below is the script I have written to change the value of one of the parameter in an XML file situated at a different location: #!/usr/bin/perl -w use Cwd; use XML::Simple; use Data::Dumper; no warnings; my $before_upgrade_value = &pre_upgrade_value; print "Value before upgrade:: $before_upgrade_value \n"; &change_value ($before...

Using Perl, how can I create charts using values in a CSV file?

I am new to this and need a clue on how to do this task. I have a csv file with following sample data: site,type,2009-01-01,2009-01-02,.... X,A,12,10,... X,B,10,23,... Y,A,20,33,... Y,B,3,12,... and so on.... I want to create a perl script to read data from the csv file (as per the given user input) and create XY(scatter) charts. Let...

C++-like usage of Moose with Perl for OOP

I've been playing around with Moose, getting a feel for it. I'd like an example of pure virtual functions like in C++ but in Moose parlance (specifically in a C++-looking way). I know that even with Moose imposing a stricter model than normal Perl, there's still more than one way to do what I'm asking (via method modifiers or SUPER:: cal...

How can I iterate over a Perl array reference?

I have an array that is a member of an structure: $self->{myArray} = ["value1", "value2"]; And I'm trying to iterate over it using the following code: my @myArray = $self->{myArray}; foreach my $foo (@myArray){ #Do something with the using $foo ... } The problem is that the 'foreach' loop is executed only once (when I would...

Is there a tool for extracting all variable, module, and function names from a Perl module file?

My apologies if this is a duplicate; I may not know the proper terms to search for. I am tasked with analyzing a Perl module file (.pm) that is a fragment of a larger application. Is there a tool, app, or script that will simply go through the code and pull out all the variable names, module names, and function calls? Even better would ...

MDB 2 CSV batch.

Does anybody know what I could use to write a script to convert all MDB files in a directory to CSV files? I'm working on Windows but have been using Cygwin for some work. ...

Programming a Self Learning Music Maker

I want to learn how to program a music application that will analyze songs. How would I get started in this and is there a library for analyzing soundwaves? I know C, C++, Java, Python, some assembly, and some Perl. Related question: Algorithm for music imitation ...

How can I redirect the test output from Perl's Test::Simple?

I am writing a simple test automation suite that will tell me the number of test cases passed and failed. Below is a simple example that will describe the code: #! /usr/bin/perl -w use Test::Simple tests => 1; print "Enter the name of the Book: "; $name = <STDIN>; chomp($name); print "You have entered $name \n"; $ori_name = "TextBoo...

Perl: Get .htaccess status on the current folder

I have developed sort of a Server Explorer as a module for our web application, and it actually works great. I am doing some refinements to it and there is one problem I don't really know how to tackle. The Explorer is mainly used to choose pictures from a specified folder and subfolders. As some schools are concerned with distribution...

When should I use the & to call a Perl subroutine?

I have heard that people shouldn't be using '&' to call Perl subs, i.e: function($a,$b,...); # opposed to &function($a,$b,...); I know for one the argument list becomes optional, but what are some cases where it is appropriate to use the '&' and the cases where you should absolutely not be using it? Also how does the performace incre...

Summing up two columns the Unix way

# To fix the symptom How can you sum up the following columns effectively? Column 1 1 3 3 ... Column 2 2323 343 232 ... This should give me Expected result 2324 346 235 ... I have the columns in two files. # Initial situation I use sometimes too many curly brackets such that I have used one more this { than this } in my f...

How can I reverse a string that contains combining characters in Perl?

I have the the string "re\x{0301}sume\x{0301}" (which prints like this: résumé) and I want to reverse it to "e\x{0301}muse\x{0301}r" (émusér). I can't use Perl's reverse because it treats combining characters like "\x{0301}" as separate characters, so I wind up getting "\x{0301}emus\x{0301}er" ( ́emuśer). How can I reverse the str...

How can I tell if two image files are the same in Perl?

I have a Perl script I wrote for my own personal use that fetches image files from a website periodically. It then saves these images to a folder. These image files are quite often the same from fetch to fetch, and I'd like to not save duplicates if I can get around it. My question: What would be the best way to compare/check if they ...

How can I reinitialize Perl's STDIN/STDOUT/STDERR?

I have a Perl script which forks and daemonizes itself. It's run by cron, so in order to not leave a zombie around, I shut down STDIN,STDOUT, and STDERR: open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>>/dev/null' or die "Can't write to /dev/nu...

How can I provide a temp file download using mod_perl and CGI::Application?

My web app runs on Apache mod_perl using CGI::Application. I want to provide a download of a generated file. In the past (before we were using mod_perl and CGI::App) I just spooled out a csv file to STDOUT as it was generated. Now I'm shooting for a little more refinement - creating an Excel spreadsheet using Spreadsheet::WriteExcel -...

What is the fastest way to read 10 GB file from the disk?

We need to read and count different types of messages/run some statistics on a 10 GB text file, e.g a FIX engine log. We use Linux, 32-bit, 4 CPUs, Intel, coding in Perl but the language doesn't really matter. I have found some interesting tips in Tim Bray's WideFinder project. However, we've found that using memory mapping is inherent...

In Perl, is there graceful way to convert undef to 0 manually?

I have a fragment in this form: my $a = $some_href->{$code}{'A'}; # a number or undef my $b = $some_href->{$code}{'B'}; # a number or undef $a = 0 unless defined($a); $b = 0 unless defined($b); my $total = $a + $b; The reality is even more messy, since more than two variables are concerned. What I really want to write is this: my $t...

Why don't more C programs embed Perl?

I know there is a way to call Perl routines from C. As shown here http://search.cpan.org/dist/perl/pod/perlcall.pod#NAME But, still I do not see a widespread use of this by C programmers. Has any one used this ...ever? or any idea what are the reasons that it is not used so much? ...