perl

How can I call Perl from my PHP page on apache?

Hi, my friend and I are creating a log parser for a series of games. We have written the frontend (web) in PHP/MySQL and the parser in Perl (also using MySQL, of course). Now we are having problems getting these two to communicate. All we wan't to do is this: one administration page online where you have the button "parse". When you cli...

In Windows, what's the most efficient way to compare two files and return just the records missing in the second file that were originally present in the first file?

At regular intervals we are receiving CSV files from an external source that we have little control over. These files are complete sets of current records; however, any records that have been deleted since the previous are not present. We would like to compare the two files and create a separate file of deleted records so we can do som...

Why can't I disconnect my database handles with DBD::DB2?

My perl script is slow but works. I am considering throwing it out and building a true DB2 application with proper binds and such; however, in the meantime I want this to work as a place holder. I looked at this documentation and it mentions: $dbh->disconnect(); However I cannot use it because it throws this error. Can't locate...

Is HTML::StripScripts still safe for removing modern exploits?

I need a way in Perl to strip naughty things, such as XSS, image interjection, and the works. I found HTML::StripScripts but it hasn't updated in close to two years, and I'm not up to date with all the new exploits. Is it safe? What other markups languages (in Perl) would you use? ...

How can I sprintf a big number in Perl?

On a Windows 32-bit platform I have to read some numbers that, this was unexpected, can have values as big as 99,999,999,999, but no more. Trying to sprintf("%011d", $myNum) them outputs an overflow: -2147483648. I cannot use the BigInt module because in this case I should deeply change the code. I cannot manage the format as string, ...

How do I assign many values to a particular Perl variable?

I am writing a script in Perl which searches for a motif(substring) in protein sequence(string). The motif sequence to be searched (or substring) is hhhDDDssEExD, where: h is any hydrophobic amino acid s is any small amino acid x is any amino acid h,s,x can have more than one value separately Can more than one value be assigned to o...

How do I convert date formats in Perl without importing external modules?

Probably an easy answer: how do I convert this without importing external modules? I've read the CPAN but couldn't explicitly pinpoint a method that does the following: Convert: 20080428 to 28-APR-08 Any ideas? Even directing me to a tutorial would be appreciated. Regards, PIAS ...

How can I make hundreds of simultaneously running processes communicate with a database through one or few permanent sessions?

Long speech short: How can I make hundreds of simultaneously running processes communicate with a database through one or few permanent sessions? The whole story: I once built a number crunching engine that handles vast amounts of large data files by forking off one child after another giving each a small number of files to work on. Fil...

Do Perl CGI programs have a buffer overflow or script vulnerability for HTML contact forms?

Greetings all, My hosting company says it is possible to fill an HTML form text input field with just the right amount of garbage bytes to cause a buffer overflow/resource problem when used with Apache/HTTP POST to a CGI-Bin Perl script (such as NMS FormMail). They say a core dump occurs at which point an arbitrary script (stored as p...

Can I use Perl CGI::Sessions data in PHP?

I'm using Perl's CGI::Session with MySQL. No problems there. I want to incorporate some other languages, most notably PHP, to use the same session cookie. How would I do that? Almost the entire site is in Perl, but I want to use free PHP things, like forums and mediawiki, and still use the same session cookie. ...

Can I use a Perl constant in the glob operator?

I'm parsing XML files with something like: while (<files/*.xml>) { ... } I want to use a constant to 'files', say use constant FILES_PATH => 'files'; while (<FILES_PATH/*.xml>) { ... } I hope you understand the idea, and can help me :).. Thank you in advance. ...

Is there a Perl module to interface to Google Contacts API?

I want to write a command line program to add a contact to GoogleMail. WWW::Contact::GoogleContact appears only to be able to get things from Google. ...

Search for motif in protein sequence?

I have written the following script to search for a motif(substring) in a protein sequences(strings). I am beginner and writing this has been tough for me. I have two questions regarding the same: 1. Errors: The following script has few errors. I have been at it for quite sometime now but have not figured out what and why? 2. The followi...

How can I find multiple motifs(substring) in a protein sequence(string)?

The following script is for finding one motif in protein sequence. use strict; use warnings; my @file_data=(); my $protein_seq=''; my $h= '[VLIM]'; my $s= '[AG]'; my $x= '[ARNDCEQGHILKMFPSTWYV]'; my $regexp = "($h){4}D($x){4}D"; #motif to be searched is hhhhDxxxxD my @locations=(); @file_data= get_file_data("seq.txt"); $protein_se...

How do I find the index location of a substring matched with a regex in Perl?

I am iterating through a file and on each line I am looking for a regex. If the regex is found I just want to print "it's found" and then the index location of where it was found in that line. Example: looking for: 'HDWFLSFKD' need index between two Ds line: MLTSHQKKF*HDWFLSFKD*SNNYNSKQNHSIKDIFNRFNHYIYNDLGIRTIA output: 'its found' in...

How can I extract a bunch of numbers from a string?

Hi. This is the sample test file: Barcode:*99899801000689811* JSC4000I accountNumber:10006898Sequence Number:998 Envelopes: 1 LCD5010V Using jsl 'CUSOFF' for output page '6' Barcode:*99999901000673703* LCD5010V Using jsl 'CUSOFF' for output page '4' LCD5005V Using job 'A' for current page '4' So, in this file, how to s...

Find multiple substrings in strings and record location

The following is the script for finding consecutive substrings in strings. use strict; use warnings; my $file="Sample.txt"; open(DAT, $file) || die("Could not open file!"); #worry about these later #my $regexp1 = "motif1"; #my $regexp2 = "motif2"; #my $regexp3 = "motif3"; #my $regexp4 = "motif4"; my $sequence; while (my $line = <DA...

Why would I use Perl anonymous subroutines instead of a named one?

I'm just curious why one would choose to use an anonymous subroutine, versus a named one, in Perl. Thanks. ...

Why does Perl's DBI complain about "Fetch attempted on unopen cursor"?

Here is my script: $db_handle=DBI->connect("$dbstr", "", "", {RaiseError => 0, AutoCommit => 0, PrintError => 1}) || die "Connect error: $DBI::errstr" ; $result=$db_handle->selectrow_array("set isolation to dirty read"); Note: $dbstr is a valid database name. I am not a database programmer. What am I doing wrong which is causing the...

How to get to my anonymous arrays?

The following code generates a list of average number of clients connected by subnet. Currently I have to pipe it through sort|uniq|grep -v HASH. Trying to keep it all in perl this doesn't work: foreach $subnet (keys %{keys %{keys %days}}) { print "$subnet\n"; } Source is this: foreach $file (@ARGV) { open(FH, $file) ...