perl

[Perl] Append a text File inside a Zip

I have zip file inside a Text file (file.txt inside a file.zip) and I would like to append to this file another text file file.txt outside the zip file. How can I do this? Is there a solution? I've tried to add Append =>1 parameters to IO::Compress::Zip but the file inside the zip been overwritten .. use IO::Compress::Zip qw(zip $ZipEr...

Strange behavior of '\' under mod_perl

I have the following in a script that runs under mod_perl Logger::log("\$1 = '$1'"); Logger::log("\$ 1 = '$1'"); Logger::log("\\$1 = '$1'"); Which outputs the following into my log file: logger: = '' logger: $ 1 = '' logger: \ = '' $1 is known to be null. Is this a bug in mod_perl2 or is it something else I'm missing? ...

Having trouble interfacing with cleaquest API with cqperl.

I'm having trouble setting up a filter for a query in cqperl. I'm trying to build a pretty simple filter to query based on a defect id, but I'm getting the following error: Failed condition: AdIsValidCompOp (op). The code is as follows: my $querydef = $session -> BuildQuery("defect"); my @dbfields = ("id", "headline", "owner.login_n...

Get/Set innerHTML in Perl HTML::TreeBuilder?

Get/Set innerHTML in Perl HTML::TreeBuilder? I could get innerHTML but dont know how to set. Thanks in Advance. ...

Cleanup Perl code: my $export = $doc; $export =~ s:\.odt:\.pdf:;

Perl code fragment: my $export = $doc; $export =~ s:\.odt:\.pdf:; How would this be written cleaner? Not simply what are 900 other ways to write it, TMTOWTDI. ...

Which Perl moudle can handle variety of date formats with unicode characters ?

My requirement is parsing xml files which contains wide varieties of timestamps based on the locales at which they are written. They may contain Unicode characters in case of Chinese or Korean locales. I have to parse these timestamps and put then in a standard format something like 2009-11-26 12:40:54 to put them in a oracle database. S...

When does ref($variable) return 'IO'?

Here's the relevant excerpt from the documentation of the ref function: The value returned depends on the type of thing the reference is a reference to. Builtin types include: SCALAR ARRAY HASH CODE REF GLOB LVALUE FORMAT IO VSTRING Regexp Based on this, I imagined that calling ref on a filehandle would return 'IO'. Surprisingl...

How to integrate C++ function that can throw the MyException in swig interface file

Hi, I am new to swig,using swig for integrating c++ code to Perl,I have c++ function like void s() throw MyException. How i can integrate the c++ function that can throw the MyException in the swig interface file.How i can called the c++ function in Perl. Any Help in this regard is highly appreciated. ...

Question about Perl logger - Log::Log4perl

I need to configure Log::Log4perl to make the following: Some type of messages write to file only. Another type of messages write to file and print to screen as well. ...

File::Find and $_ in nested subroutines.

When running the following code, the filenames of all files below C:\Test are printed. Why doesn't it print just Hello (n times, depending on how many files are processed)? Does this imply that I cannot rely on shift to reliably assign to $_? Imagine a coworker implements the wtf function and doesn't know that it's called from a File::...

perl captcha doesn't refresh on windows 7

I have created a captcha which looks like this: <img src="/cgi-bin/rand.pl" /> The problem is that if someone navigates away from or back to the page with the captcha on it, it doesn't refresh which makes the captcha invalid (especially if they have already submitted the form before) Is there anyway to force a refresh as I suspect set...

What is wrong with this substitution?

#!/usr/bin/perl use strict; use warnings; my $s = "sad day Good day May be Bad Day "; $s =~ s/\w+ \w+/_/gm; print $s; I am trying to substitute all spaces between words with _, but it is not working. What is wrong with that? ...

Question : Perl map - need to map a array into a hash as arrayelement->array_index

Hi folks. I have a array like this: my @arr = ("Field3","Field1","Field2","Field5","Field4"); Now i use map like below , where /DOSOMETHING/ is the answer am seeking. my %hash = map {$_ => **/DOSOMETHING/** } @arr Now I require the hash to look like below: Field3 => 0 Field1 => 1 Field2 => 2 Field5 => 3 Field4 => 4 Any help? ...

Why does File::Slurp return a scalar when it should return a list?

I am new to the File::Slurp module, and on my first test with it, it was not giving the results I was expecting. It took me a while to figure it out, so now I am interested in why I was seeing this certain behavior. My call to File::Slurp looked like this: my @array = read_file( $file ) || die "Cannot read $file\n"; I included the "...

Replace commas in csv file

Hi, I am using perl to a parse a raw database dump to a csv file. The problem is that it's not formatted correctly for Excel. I need to add a header to the top of the file, and also remove all the commas. This could be done in a perl one liner, but this is part of a larger perl script so I want to do it in the main perl script. I was tr...

How do I get an array of days of the month with Perl Date::Manip?

I'm using Date::Manip http://search.cpan.org/~sbeck/Date-Manip-6.11/lib/Date/Manip.pod for a variety of things, and want to create an array of days of the month. I think I need: @date = &ParseRecur("2010:4:0:0:0:0:0"); but, it doesn't do it. I've read & reread the man page but can't get the syntax. @date = &ParseRecur("2010:4:0:1:0:...

Perl compile error on: "my ($export = $doc) =~ s{\.odt}{\.pdf};"

Based upon SO answer "my ($export = $doc) =~ s{.odt}{.pdf};" why does this Perl script produce a compile error? $ cat so.pl #!/usr/bin/perl my $doc ="x.odt"; my ($export = $doc) =~ s{\.odt}{.pdf}; $ ./so.pl Can't declare scalar assignment in "my" at ./so.pl line 3, near ") =~" Execution of ./so.pl aborted due to compilation errors. ...

DBIC generates an "Invalid precision" error for a primary key

The table stores file names. The primary key is an auto-incrementing integer. A search using the result set works. And calling the delete method generates the following error message: DBIx::Class::Relationship::CascadeActions::delete(): DBI Exception: DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Invalid precision v...

What is equivalent LDAP attributes for Active Directory

What is equivalent LDAP attributes for Active Directory I am looking for password using Net::LDAP. I dont know to how to set the user password using Net::LDAP ...

Reading custom values in Ebay RSS feed (XML::RSS module)

I've spent entirely way too long trying to figure this out. I'm using XML:RSS and Perl to read / parse an Ebay RSS feed. Within the area, I see these entries: <rx:BuyItNowPrice xmlns:rx="urn:ebay:apis:eBLBaseComponents">1395</rx:BuyItNowPrice> <rx:CurrentPrice xmlns:rx="urn:ebay:apis:eBLBaseComponents">1255</rx:CurrentPrice> Howeve...