perl

Loading iframe from bookmarklet on 3rd party sites kills CakePHP Session

Hi folks, I am trying to pop up an iframe from a bookmark whose contents are from my test app. The test app doesn't do much but let me log in and set some session vars. First I developed this using Perl's Catalyst framework, and it worked great. I could log in to the test app in some window, or the iframe, and it would keep the session ...

Convert Between Datetime Formats Using Perl

We're currently using a 3rd party API that provides datetime in the following format: Sat Mar 06 09:00:00 ICST 2010 Fri Feb 19 19:30:00 JDT 2010 Fri Feb 19 19:30:00 PST 2010 However, we want to store these datetime objects in MySQL in a standard datetime field which requires the following format: YYYY-MM-DD HH:MM:SS Right now we're...

How can I run and end the script() linux command from Perl?

#!/usr/bin/perl $sim = "multiq"; `make SCHED=$sim`; `script > scripter`; `echo hi`; print pack("c", 04); ~ This script hangs when script is called. Not sure how to get the perl script to keep running. ...

Java equivalent of Perl's s/// operator?

I have some code that I'm converting from Perl to Java. It makes pretty heavy use of regular expressions, including the s/// operator. I've been using Perl for a long time and am still getting used to the Java way of doing things. In particular, Strings seem more difficult to work with. Does anyone know of or have a Java function tha...

How do I dereference a hash that's been returned from a method of a class?

I have a class with a method that returns a hash. Ordinarily, I would get the result like so: %resp = $myclass->sub($foo); And then access members of the returned hash like this: $resp{key}{subkey}; in the case of a 2d hash. I figure there must be a way to combine this into a single, elegant line, something like this: $myclass->...

Why aren't both versions of this code failing the -c Perl check?

The new method of Parse::RecDescent has this prototype: sub new ($$$) { # code goes here } and if I create an object like this: my $parser = Parse::RecDescent->new($grammar); it will create a parser, and the method will receive 2 parameters "Parse::RecDescent" and $grammar, right? If I try to create an object like: Parse::RecDe...

Why does Perl's Crypt::SSLeay timeout on Intel Mac OS X machines?

A have a Perl cron job that recently started having its HTTPS connections start failing with an error of "500 SSL read timeout". I've tracked that the error is being thrown as part of an alarm in Crypt::SSLeay, but I don't know if this is simply something taking too long to respond. So far, I've adjusted the timeout from the default 30...

Removing text inside parens, but not the parens in Perl

OK, I got a weird one that I've been jamming on for awhile (fri afternoon mind does not work I guess). Does anyone know of a away to parse a string and remove all of the text inside parens without removing the parens themselves...but with deleting parens found inside. ie. myString = "this is my string (though (I) need (help) fixing it...

Using Rose::DB::Object, how can I auto create an object in a relationship if not found?

I have 2 tables that are 1-to-[0/1]. Is there a way to auto create the relationship object/row using Rose::DB::Object: For example: # detailed_summary is the 1-to-1 relationship # if detailed_summary exist, get it # if not, create a new one with links? $obj->detailed_summary Maybe a trigger? ...

How do I add relationships at runtime using DBIx::Class and Catalyst?

In the application I am building, users can specify relationships between tables. Since I only determine this at runtime, I can't specify has_many or belongs_to relationships in the schema modules for startup. So given two tables; system and place, I would like to add the relationship to join records between them. I have part of the ...

How do I check scalar for an 'inf' value in Perl?

Possible Duplicate: How do I create or test for NaN or infinity in Perl? How can I check, if scalar holds inf value? I check NaN as $scalar != $scalar, what to do with inf? $scalar == inf does not work, since inf is a bareword ...

How can I re-use WHERE clause logic with DBI?

Hi all: Disclaimer: first time I've used DBI. I have a MySQL table with a lot of indexed fields (f1, f2, f3, etc) that are used to generate WHERE clauses by long-running processes that iterate over chunks of the database performing various cleaning and testing operations. The current version of this code works something like this: s...

Should I establish inheritance at compile-time rather than runtime, and if so why?

AFAIK inheritance in Perl is usually set up like this: package Mule; our @ISA = ("Horse", "Donkey"); Are there any examples where use base (or use parent) is better instead? ...

Why doesn't my Perl program output anything to my file?

I'm trying to write in file ~/.log but file is remaining empty. I don't know why this is happening, everything seems fine. My system is Ubuntu 9.10amd64, Perl 5.10. #!/usr/bin/perl # vim:set filetype=perl: use strict; use warnings; use LWP::Simple qw||; use Net::SMTP; # Only because log file $| = 1; my $match_string = "... some tex...

How do I cause a CGI program to run when someone clicks on a button?

I have a Perl CGI program in which I designed an HTML form. If somebody clicks on a button in this form, a CGI/Perl subroutine in this file is executed. Because I have more than one buttons in the form, I set their types as "Button", not "Submit". This is a bookstore website, I have three buttons each for a kind of books (for example,...

Will Perl be the bottleneck in this kind of image processing?

The processing I have in mind is this: there are thousands of png files each of them should be loaded, and its pixels accessed each pixel's channels will be processed in some way, and then written to a binary file I was thinking of using some sort of module, like ImageMagick wrappers, or some other wrapper for a C image processing ba...

How can I pack an int as 32 bits big endian in Perl?

Consider this snippet: use strict; use warnings; my $data = "1"; my $packed = pack("I",$data); open(my $file,">","test.bin") || die "error $!\n"; binmode $file; print $file $packed; The thing is, trying to read it from another language, this appears to be little endian. Is there any template argument that allows me to write it as big...

How can I store captures from a Perl regular expression into separate variables?

I have a regex: /abc(def)ghi(jkl)mno(pqr)/igs How would I capture the results of each parentheses into 3 different variables, one for each parentheses? Right now I using one array to capture all the results, they come out sequential but then I have to parse them and the list could be huge. @results = ($string =~ /abc(def)ghi(jkl)mno(...

How can I get Perl's debugger and gVim to work together on Linux?

Is there a way to get Perl's debugger and gVim to work together on Linux? I.e. step through code in gVim and see the values of watched variables controlling the debugger from within gVim? ...

How can I access forms without a name or id with Perl's WWW::Mechanize?

I am having problems with my Perl program. This program logs in to a specific web page and fills up the text area for the message and an input box for mobile numbers. Upon clicking the 'Send' button, the message will be sent to the specified number. I already got it to work for sending messages. But the problem is I can't make it work fo...