perl

Using Win32::OLE to execute macro in Access 2007

Currently I am trying to execute a macro in Microsoft Access through Perl OLE I am wondering how to properly make the call to run a macro. I have tried 1) $oDatabase -> DoCmd.RunMacro("Macro1"); 2) $oDatabase -> DoCmd -> RunMacro("Macro1"); But they throw me "Can't call method "DoCmd" on an undefined value" or "useless use of concaten...

Is there an way to programatically read a file from a TrueCrypt disk into memory?

I need to load a file from an umounted TrueCrypt disk into memory. Is there any way to do this programatically? Does TrueCrypt offer an API? The way I believe is best for attempting this would be to mount the volume (prompting the user for a password, of course), open the file, and then unmount the volume. Is there a way to do this a...

How can I have link text with a URL in Pod's L<>?

The L<name> formatting code allows you to set the display text for the link if you're linking to other POD, as in L<Display Text|link_dest>, but this isn't allowed for L<scheme:...> links, such as L<http://perldoc.perl.org/strict.html&gt; How do I specify a display text for such links? Alternatively, how do I manually write such a li...

How can I check for the existence of UTF-16 filenames in Perl?

I have a textfile encoded in UTF-16. Each line contains a number of columns separated by tabs. For those who care, the file is a playlist TXT export from iTunes. Column #27 contains a filename. I am reading it using Perl 5.8.8 in Linux using code similar to: binmode STDIN, ":encoding(UTF-16)"; while(<>) { chomp; my @cols = s...

How can I turn my Perl array to XML?

How can I take a Perl array like this @categories = ( ["Technology", "Gadgets"], ["TV &amp; Film"] ); and generate this XML snippet? <itunes:category text="Technology"> <itunes:category text="Gadgets"/> </itunes:category> <itunes:category text="TV &amp; Film"/> I can change the array if there's an easier way to get to the same ...

How can I remove a file based on its creation date time in Perl?

My webapp is hosted on a unix server using MySQL as database. I wrote a Perl script to run backup of my database. The Perl script is inside the cgi-bin folde and it is working. I only need to set the cronjob and run the Perl script once a day. The backups are stored in a folder named db_backups,. However, I also want to add a command i...

How do I get output in a Perl process started from Win32::Process?

I have a Perl script that launches another Perl script in a new console through Win32::Process as follows: Win32::Process::Create($ProcessObj, "C:\\Perl\\bin\\perl.exe", "$path_to_other_perl_script", 0, NEW_CONSOLE, "."); $Proc...

How do I create an array of hashes and loop through them in Perl?

I'm trying to create an array of hashes, but I'm having trouble looping through the array. I have tried this code, but it does not work: for ($i = 0; $i<@pattern; $i++){ while(($k, $v)= each $pattern[$i]){ debug(" $k: $v"); } } ...

How can I play multiple files in an AGI script?

I am able to stream multiple files together using: $AGI->exec('Background',"file1&file2&file3&file4") However, this doesn't return the key pressed by the user when the files are being played. So, I used $AGI->stream_file, which returns the key pressed, but only plays a single file. I need to be able to play multiple files together, t...

Why doesn't the .* consume the entire string in this Perl regex?

Why doesn't the first print statement output what I expect: first = This is a test string, sec = This is a test string Since both * and + are greedy, why does the the inner * i.e. inside the "((" in the first match not consuming the entire string? use strict; use warnings; my $string = "This is a test string"; $string =~ /((.*)*)/; ...

Perl variable scope question

So I have a Perl class. It has a sort() method, and I want it to be more or less identical to the built-in sort() function: $object->sort(sub ($$) { $_[0] <=> $_[1] }); But I can't do: $object->sort(sub { $a <=> $b }); Because of scoping. But the List::Util module does this with reduce(). I looked at the List::Util module, and they...

How can I send the content of file as email in Perl?

I have a log that gets created from a bunch of cron jobs. My task now is to send specific logs (e.g. error outputs) as an email. What is the best way to get content from a file and send it as an email? I have already figured out how to send email in perl. I just need to figure out how to read in the file and put it as the text of the em...

How do I find the length of a Unicode string in Perl?

The perldoc page for length() tells me that I should use bytes::length(EXPR) to find a Unicode string in bytes, or and the bytes page echoes this. use bytes; $ascii = 'Lorem ipsum dolor sit amet'; $unicode = 'Lørëm ípsüm dölör sît åmét'; print "ASCII: " . length($ascii) . "\n"; print "ASCII bytes: " . bytes::length($ascii) . "\n"; prin...

How do I get values from the link table in DBIx::Class?

In my app I have 2 table, books and tags, and the link table book_tags. The link table also contains the number of times the book was tagged with this particular tag. I can add a tag by doing $book->add_tag($tag, { tag_count => 10 }); However when I retrieve the tags for a book @tags = $book->tags(); it does not seem to return the ...

How can I create a path with all of its subdirectories in one shot in Perl?

If you have a path to a file (for example, /home/bob/test/foo.txt) where each subdirectory in the path may or may not exist, how can I create the file foo.txt in a way that uses "/home/bob/test/foo.txt" as the only input instead of creating every nonexistent directory in the path one by one and finally creating foo.txt itself? ...

Capturing Non-Zero Elements, Counts and Indexes of Sparse Matrix

I have the following sparse matrix A. 2 3 0 0 0 3 0 4 0 6 0 -1 -3 2 0 0 0 1 0 0 0 4 2 0 1 Then I would like to capture the following information from there: cumulative count of entries, as matrix is scanned columnwise. Yielding: Ap = [ 0, 2, 5, 9, 10, 12 ]; row indices of entries...

How can I compare dates in different formats in Perl?

Can anyone help me how to convert this date format "Mon, 24 Aug 2009 17:00:44 +0800" into something like this, "2009-08-24 17:00:44" in Perl? I've been browsing in CPAN for modules, but still I wasn't able to find what I was looking for. The first format is retrieved from an email account using Mail::POP3Client. The other one is from a q...

Why don't the keys with empty string values for Perl's %ENV show up Windows subprocesses?

I want to (need to) start a sub-process from a perl script that checks certain environment variables. In one instance the environment variable needs to be there but empty. $ENV{"GREETING"} = "Hello World"; # Valid $ENV{"GREETING"} = ""; # also valid I can set $ENV{"GREETING"} = ""; and in that perl script $E...

What does this Regular expression do?

I'm in the processing of converting a program from Perl to Java. I have come across the line my ($title) = ($info{$host} =~ /^\s*\(([^\)]+)\)\s*$/); I'm not very good with regular expressions but from what I can tell this is matching something in the string $info{$host} to the regular expression ^\s*(([^)]+))\s*$ and assigning the mat...

In Perl, how can I change an element in an XML file without changing the format of the XML file?

Hi, I have a XML file of the format: <outer1> <inner1> <name>Stonecold</name> <profession>warrior</profession> <org>wwf</org> </inner1> <inner1> <name>Shanebond</name> <profession>Bowler</profession> <org>newzealand</org> </inner1> <inner1> <name>brain schemidit</name> <profes...