I am attempting to parse a string in Perl with the format:
Messages pushed to the Order Book queues 123691 121574 146343 103046 161253
I want to access the numbers at the end of the string so intend to do a match like
/(\d+)/s
My issue is that the number of values at the end contain a variable number of strings.
What is the best wa...
I'm using Module::Build to perform build, test, testpod, html, & install actions on my Perl module that I'm developing. The HTML files that are generated are okay, but I'd be much happier if I could somehow configure Module::Build to use the perltidy -html formatting utility instead of its own HTML formatter.
Anyone know of a way I c...
I'm looking for the shortest or most optimized solution for a simple game that generates a random number from 1 to 10 and then asks a user to enter their guess. If the user guesses the number then it's a win, if they don't guess then the program should say that it was either more or less than that.
Here's my solution to this:
#c:\Perl...
I'm making a script that goes through a table that contains all the other table names on the database. As it parses each row, it checks to see if the table is empty by
select count(*) cnt from $table_name
Some tables don't exist in the schema anymore and if I do that
select count(*)
directly into the command prompt, it returns...
I'm having a hard time trying to remove the colons in a list of MAC addresses.
My file:
00:21:5A:28:62:BF
00:24:81:0A:04:44
Expected Output:
00215A2862BF
0024810A0444
Any ideas on how could I do this?
Thanks a lot in advance.
...
I'm writing a forum-type discussion board in Perl and would like to change automatically http://www.google.com to be an HTML link. This should also be safe, and err on the side of security. Is there a quick, easy, and safe way to add links automatically?
...
Adding 15 digit numbers like 999999999999990 in Perl produces results with a period
such as 1.9999999999999e+. When using substr it still produces 1.99999999999, and when using BigInt the result still has a period. What is the correct Perl syntax for Perl 5.8.7 to get the result without the period?
use BigInt;
$acct_hash = substr(($acct...
How do I include a Perl module that's in a different directory? It needs to be a relative path from the module that's including it.
I've tried
push ( @INC,"directory_path/more_path");
also
push ( @INC,"directory_path\\more_path");
Thank you!
...
If I do use a big integer in substr:
use BigInt;
$acct_hash = substr(('99999999999912345' + $data[1]),0,15);
why is the result still 9.9999999999912?
I was expecting 999999999999912. Is there something like:
$data[1] = substr(to_char('999999999999991234'),0,15);
in Perl?
...
Are there any transparent library that I can use or something easy so I can prevent cross-site request forgery (CSRF) with Perl and Apache? How can I generate tokens for forms and validating them server-side?
...
I get the following output after running the code for a picture
[1459]./image_info.pl lah.png
$VAR1 = {
'width' => 206, 'file_media_type' => 'image/png',
'file_ext' => 'png',
'PNG_Chunks' => [
'IHDR',
?V?????O?H??^#?C&?fu?M?5V??m6???M?s',
'IE...
I would expect the block in the second 'if' statement to be entered because of the undef value but the logs show that it isn't being entered.
sub getcmd{
my $self = $_[0];
if ( $self->_recv == OK ){
push @{$self->{'log'}}, ['NOTICE', "OK"];
return "My command";
}
push @{$self->{'log'}}, ['ERROR', "Did not g...
See also: Where in the documentation does it say that while tests readdir for definedness?. (Not a duplicate; just closely related.)
Many people treat the loop below as idiomatic:
while (defined(my $file = readdir($dir)) {
...
}
instead of:
while (my $file = readdir($dir)) {
...
}
because supposedly with the latter vers...
So my Perl script basically takes a string and then tries to clean it up by doing multiple search and replaces on it, like so:
$text =~ s/<[^>]+>/ /g;
$text =~ s/\s+/ /g;
$text =~ s/[\(\{\[]\d+[\(\{\[]/ /g;
$text =~ s/\s+[<>]+\s+/\. /g;
$text =~ s/\s+/ /g;
$text =~ s/\.*\s*[\*|\#]+\s*([A-Z\"])/\. $1/g; # replace . **** Begin or . #### B...
What's the best way to dump a MySQL table to a file in Perl?
I've been using:
open( FILE, ">$filename" );
my $sth=$dbh->prepare("select * from table");
$sth->execute();
while ( my $row = $sth->fetchrow_arrayref ) {
print FILE join( "|", @$row ), "\n";
}
...
My Perl app and MySQL database now handle incoming UTF-8 data properly, but I have to convert the pre-existing data. Some of the data appears to have been encoded as CP-1252 and not decoded as such before being encoded as UTF-8 and stored in MySQL. I've read the O'Reilly article Turning MySQL data in latin1 to utf8 utf-8, but although it...
Is there a neat way of making a case or switch statement in Perl 5?. It seems to me they should include a switch on version 6..
I need this control structure in a script, and I've heard you can import a "switch module". But how can I achieve it without imports to minimize dependencies and acquire portability?
...
See also: How is "0" result from readdir not false in a while condition?. (Not a duplicate; just closely related.)
Where in the documentation does it say that while tests readdir for definedness? For instance, this code
#!/usr/bin/perl
use strict;
use warnings;
opendir my $dir, "/tmp" or die "$!";
while (my $file = readdir($dir)...
I'm writing an application to do proxying and rewriting of webpages on the fly and am pretty settled on using mod_perl2 - there is an existing implementation using mod_perl (v1) that I'm working from. In mod_perl2, there's this idea of APR::Brigades and APR::Buckets which, from my vague understanding, are an efficient way to do the sort...
I have perl installed, but many commands (perl utilities) are not available. I thing they should be come along with perl after perl is installed. But there are simply no such commands. And I googled to find where I can download them, but looks like nowhere tells me where to get them.
root@opensolaris:~# which find2perl
which: no find...