perl

comparing PERL md5() and PHP md5()

Hello again. All of my application is written in PHP, bar 1 script which happens to create a md5 hash which is used later via PHP scripts. Problem being they dont match up. PERL: #$linkTrue = 'http://www.themobilemakeover.co.uk/mobile-makeover-appointment-booking-signup.php' md5_hex($linkTrue); And for testing purposes i did this i...

How can I identify Windows PnP events with Perl's POE?

Is there a POE module that identifies PnP events in Windows? If yes, could someone provide idea code snippet? ...

How do I read a file's contents into a Perl scalar?

Hi, what i am trying to do is get the contents of a file from another server. Since im not in tune with perl, nor know its mods and functions iv'e gone about it this way: my $fileContents; if( $md5Con =~ m/\.php$/g ) { my $ftp = Net::FTP->new($DB_ftpserver, Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->log...

How do I enable IPv6 support in LWP?

The following code ... my $user_agent = LWP::UserAgent->new; my $request = HTTP::Request->new(GET => $url); my $response = $user_agent->request($request); if ($response->is_success) { print "OK\n"; } else { die($response->status_line); } .. will fail with .. 500 Can't connect to <hostname> (Bad hostname '<hostname>') .. if ...

Why does my use of Perl's split function not split?

I'm trying to split an HTML document into its head and body: my @contentsArray = split( /<\/head>/is, $fileContents, 1); if( scalar @contentsArray == 2 ){ $bodyContents = $dbh->quote(trim($contentsArray[1])); $headContents = $dbh->quote(trim($contentsArray[0]) . "</head>"); } is what i have. $fileContents contains the HTML co...

Uploading HTML into database - PERL

Hi, im trying to upload HTML into a database which does work for some files but not all. my $fileContents; if( $md5Con =~ m/\.php$/g ) { my $ftp = Net::FTP->new($DB_ftpserver, Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login($DB_ftpuser, $DB_ftppass) or die "Cannot login ", $ftp->message; ftp->get("/" ....

In Perl, how can I check for the existence of Socket options without generating warnings?

I'm checking for the existence and default values of various socket options using Perl. #!/usr/bin/perl -w use strict; use Socket; if (defined(SO_BROADCAST)) { print("SO_BROADCAST defined\n"); } if (defined(SO_REUSEPORT)) { print("SO_REUSEPORT defined\n"); } When I run this it outputs: SO_BROADCAST defined Your vendor has ...

Why can't I insert HTML into my database?

Hi, I have errors when inserting into my database. I have tried everything to sus this. Someone mentioned usind DBI's trace() to track what is going wrong but i cannot make heads or tails of what is going on. Could someone please take a look and see what they think might be the problem. D BI 1.607-ithread default trace level set to 0x0...

ActivePerl doesn’t output fatals to browser.

LS, I'm using the following code to test the outputting of fatal errors to the browser: use CGI; use CGI::Carp qw(fatalsToBrowser); die "test"; I am expecting to see some error in the browser, but there isn't any, I just get a regular 500 response. I forgot that I had custom error pages on for remote requests, and I now get Script f...

perl IO eventhandler for untainting strings

How do I create an event handler in my Perl code to intercept all File/Directory/system-based calls, so that I can untaint input in a just-in-time fashion. I have lots of IO access in my script, and I find adding manual code for untainting cumbersome. Can this be done without need to install a third-party CPAN module? ...

Perl - using a regular expression to search for all instances yet replace only the first.

I would like to search for all instances and replace all separately, even if identical. #!/usr/bin/perl use strict; use warnings; my %dataThing; my $x=0; my $data = "1 - 2 - 2 - 4 - 7 - 343 - 3 - 1"; if( my @dataArray = ( $data =~ m/([0-9]+)/gis )){ foreach( @dataArray ) { my $replace = "[thing-" . $x . "]"; # someh...

Should I use HTML::Parser or XML::Parser to extract and replace text?

I am looking at being able to extract all plain text and analyse/amend from HTML/XHTML document and then replace if needed. Can I do this using HTML::Parser or should it be XML::Parser? Are there any good demonstrations that anyone knows of? ...

Why does my CGI script complain "Can't locate CGI/Session.pm in @INC"?

Hi All, I am having a html file which will accept and send the login and password. It is sent to the file login.cgi. ** html file ** <form method="POST" action="login.pl"> <table > <tr> <td>Username </td> <td bgcolor="lightgrey"><input type="text" name="usr" size="20"></td> </tr> <tr> <td>Password </td> <td bgcolo...

Perl - read file with encoding method?

Hi, im not too good when it comes to encoding and I am wanting to figure out how to return data as the same encoding it started with... I have a file with some characters in such as '»' by the time I have edited and and inserted into database they have turned into &raquo. decode_entities() does nothing and encode_entities encodes the c...

How can I conditionally replace a line with a single word using Perl?

I want to replace a lines that ends with 'YES' with 'YES' and replace lines that ends with 'NO'with 'NO'. I have to apply for a large file. Input: max. C 13 0.457 0.32 YES max. Y 13 0.232 0.33 NO max. S 1 0.315 0.87 NO Output: YES NO NO ...

Is MySQL more resistant to SQL injection attack than PostgreSQL (under Perl/DBI) ?

I am reviewing a Linux based perl web application that contains a login handler with the ubiquitous my $sth = $DB->prepare("SELECT password from passwords where userid='$userid'") or die; $sth->execute or die; ... where $userid is initialized from (unsafe, unfiltered) web user input. It is well known that the DBI documentation recomme...

File name matching with -e and regular expressions in perl.

I need to check for the existence of a file in a directory. The file name has a pattern like: /d1/d2/d3/abcd_12345_67890.dat In my program, I will know the file name up to abcd_ I need to write an if condition using -e option and find the files matching above given pattern. ...

How should I do RPC in Perl with Catalyst?

I've been trying to find a good form of RPC to standardize on, but so far I've ran into a ton of walls and was wondering what the stackoverflow communities view was. My ideal RPC would provide the following: Somewhat wide support in other languages, in that people shouldn't have to write a custom stack to use our server Input validat...

Common Perl memory/reference leak patterns?

I'm chasing a couple of potential memory leaks in a Perl code base and I'd like to know about common pitfalls with regards to memory (mis-)management in Perl. What are common leak patterns you have observed in Perl code? ...

How can I match the svnlook output in Perl?

I'm running SVN on a Windows server, and I'm using Perl scripts to implement some pre-commit hooks. I'm seeing the following error message from TortoiseSVN: Error !!ScriptError!! Can't parse line: _U path/to/files/trunk and this is the script: foreach my $line (`$svnlook changed -t "$txn" "$repos"`) { chomp($line); if ($line...