perl

Perl/MySQL "Query was empty" error, probably multithreading-related

I am writing a program to extract data from a bunch of text files and stuff it into DB. All of my commands currently have the form similar to this (with different queries): $query = "INSERT INTO relations (relation_type_id, confidence) VALUES ($reltypeid, $conf)"; print "$query\n"; $result = $conn->query($query); $relid = $result->inser...

Determine whether a file is in use in Perl on Windows

Hi there, I'm writing some Perl which takes TV shows recorded on Windows Media Center and moves/renames/deletes them depending on certain criteria. Since the Perl runs fairly frequently, I'd like to cleanly determine whether or not the file is in use (in other words, the show is in the process of being recorded) so I can avoid doing an...

How to properly run Perl "one liner" command line scripts?

I'm new to using Perl to call the linux command line and have looked through a number of tutorials but still can't figure out what I am doing wrong.. I am trying the code below (in a .pl perl file, as an executable): #!/usr/bin/perl perl -e 'print "Hello";' I run this script and get: "Execution of /home/user1/Desktop/file_backups.pl...

Convert a Perl code to PHP

Hi; I need to convert the following perl function to php: pack("SSA12AC4L", $id, $loc, $name, 'ar', split(/\./, $get->getIP), time+(60*60); I use the following code (to test) in PHP: echo pack("SSA12AC4L", '25', '00001', '2u7wx6fd94fd', 'f', preg_split('/\./','10.2.1.1', -1, PREG...

Perl - the fastest way to read a range of lines from a file into a variable

Given a start and end line number, what's the fastest way to read a range of lines from a file into a variable? ...

Perl - reading a file line by line in reverse order

Possible Duplicate: How can I read lines from the end of file in Perl? First read the last line, and then the last but one, etc. The file is too big to fit into memory. ...

How to detect if web script in Perl is run using ModPerl::Registry (mod_perl handler)?

Is it possible in to detect in web app run under mod_perl if it is run using ModPerl::Registry? I want to write script which would run under ModPerl::Registry (or similar handler), but can function also as mod_perl response handler. ...

Perl Mechanize, submitting a form with a file (image)?

I can't seem to find a good example of how to do this properly, the ones I have found aren't working for me.. I am trying to submit a form using perl mechanize, where the form has an image file, the form is as below, its actually a way I am trying to access this API for a website from which I have an account and using POST seems to be th...

How can I push an element into an array reference held as a hash value?

%data = ( 'digits' => [1, 2, 3], 'letters' => ['a', 'b', 'c'] ); How can I push '4' into $data{'digits'}? I am new to Perl. Those $, @, % symbols look weird to me; I come from a PHP background. ...

How to extract IP addresses from a text file using Perl?

How do I extract just the IP addresses from a text file which has an IP address per line? I would like to extract the IPs and then list the IP addresses in a separate file. The text file that contains the IPs are in the following format: Host somehost.com (192.168.1.1) is up (0.20s latency). Host 10.1.0.0 is up (0.21s latency). Host 17...

How to get the index of an element in an array?

Does Perl have a build-in function to get the index of an element in an array? Or I need write such a function by myself? [ equivalent to PHP array_search() or JavaScript array.indexOf() ] ...

HTTP::Proxy for pen testing tasks

Could someone provide ideas how HTTP::Proxy module is compared to others proxies like paros and burp proxy and if someone use it during his work specifically if it used by the pen testing community for real job ...

What is written in one file write to another

I have one file, and I need everything that is written in some time frame to that file to be written to a second file. What is the best way to do so? Open some thread that will read the file and do so ? Any ideas ? ...

What does ENDOFTEXT mean in this Perl code?

I'd like to know what ENDOFTEXT means in this Perl script: print <<ENDOFTEXT; HTTP/1.0 200 OK Content-Type: text/html <HTML> <HEAD><TITLE>Hello World!</TITLE></HEAD> <BODY> <H4>Hello World!</H4> <P>You have reached <a href="$url">$url</a></P> <P>Your IP Address is $ip</P> <H5>Have a nice day!</H5> </BODY> </HTML> ENDOFTEXT exit(0); ...

Elegantly Determining System Architecture Within Perl

I'm looking for a simple way to determine whether a system is 32- or 64-bit from within Perl 5. I have read the perlvar manual page backwards and forwards, and have not discovered a variable that contains the system's CPU architecture (the CPU architecture Perl was compiled for will come close enough). This is the closest I have come: c...

How can variables be set to NULL under the strict pragma?

use strict; my $var = NULL; will raise an error of Bareword "NULL" not allowed while "strict subs" in use ...

How can I pass arguments and return values with XML::Twig's handler?

my question is: how to pass some arguments to XML:Twig's handler, and how to return the result from the handler. Here is my code, which hardcoded: <counter name = "music", report type = "month", stringSet index = 4>. How to implement this by using arguments $counter_name, $type, $id? and how to return the result of string_list? Than...

Perl packages question

I'm new to Perl. I dowloaded a perl application, that has such a line in a source file: use PWING::Utils::Utils; It imports a file as it seems. I downloaded a plugin for Eclipse [Perl-Eclipse integration]. When I try to start that file as a perl app, it says it cannot find an imported resource. Now the question is, what a perl pa...

Iterating over an array

Possible Duplicate: automatically get loop index in foreach loop in perl I'd like to iterate over an array, but I need to keep track of the index. This code doesn't list the indexes as I'd expect - how can I fix it? $arr = [0,0,0,0]; foreach $i (0 .. scalar @$arr) { print $i; } ...

How do I make certain tables searchable by google?

I'm using perl, and I want others to find certain issues on my site using google. How can I do that? In wordpress (php) there is this option: I would like my blog to be visible to everyone, including search engines (like Google, Bing, Technorati) and archivers I would like to do the same using perl. ...