?

Log in

Perl Developer's Journal
 
[Most Recent Entries] [Calendar View] [Friends]

Below are the 20 most recent journal entries recorded in Perl Developer's LiveJournal:

[ << Previous 20 ]
Sunday, June 13th, 2010
5:33 pm
[darth_spacey]
Programming grumbles
So, I've got this Perl module, Net::IPAddress::Util, and it's not-quite-randomly failing its test suite on not-quite-random platforms.

The testing summary is here.

As you'll be able to tell (with some digging), the tests that are failing are one or more of the tests named /01-try-.*/. These tests are all sanity-checks put in place to test the underlying modules and/or libraries that my module itself actually relies on. Those tests don't even use my module -- they run directly on the underlying modules.

Now, I know for sure that the libraries themselves can't possibly be broken: they're used by gazillions of people all day every day, even for "real" comp sci problems. I'm pretty sure the Perl modules that use the libraries aren't broken: they also seem to be used by other people all day every day.

So, after eliminating the impossible, what remains is that I'm misreading the docs badly enough that even my trivial "are you alive?" tests are written badly enough that they're crashing hard.

Is anyone here ready, willing, and able to help me figure out what I'm doing wrong?
Saturday, March 27th, 2010
10:01 am
[darth_spacey]
Need help with Math::BigInt subclass
It's official. I'm completely stumped.

I need a Perl genius with a non-Linux system (preferably a small army of them) to help me figure out why this one particular subtest is failing while everything else is passing, and why it's only doing it on platforms I don't currently have direct access to:

http://matrix.cpantesters.org/?author=pwbennett

Anyone got any hints, tips or suggestions? The latest SVN source is available from:

http://code.google.com/p/perl-ipaddress-simple/source/browse/

Current Mood: aggravated
Sunday, March 21st, 2010
5:03 pm
[darth_spacey]
I'm a published CPAN author!
My little contribution can be found here. It's a set of convenience wrappers to make life easier in a mixed IPv4 / IPv6 world.
Saturday, February 27th, 2010
11:21 am
[darth_spacey]
Announcing DBIx::Nailgun (unstable alpha version)
The project hasn't got very far yet -- it's usable, but not massively functional -- but I thought I'd announce something I've been working on. It's yet another ORM module, based on the "Active Record" pattern. The goal is to make database access as transparent as possible for Perl coders: database records look & feel like hashrefs, and record sets look & feel like arrayrefs (and hashrefs, if needed).

Once I get past the "v0.01" stage, I'll be making it CPAN-ready, and moving the official project home to CPAN. For the time being, the project home is:

http://code.google.com/p/perl-dbix-nailgun/

All comments, questions, suggestions, and so forth about the project are welcome. I'd especially like suggestions about unit tests that need to be written, and tips on how to make it CPAN-ready.
Friday, October 23rd, 2009
1:42 pm
[darth_spacey]
Need help with DBD::File
Has anyone here written a module that subclasses DBD::File?

Does it still work with DBI v1.609? If so, what (if anything) did you have to do to make it work? If not, would you like to join me as I investigate what would need to be done to make it work?

Specifically, I'm trying and failing to install DBD::RAM, and kinda flailing around in a sea of badly-formatted code trying to figure out why it wont install for me.

As far as I can tell, DBD::File::db->STORE() is where it's failing (the DBD::RAM test script is trying to set a driver option, and crashing hard), but I can't yet pin down where the problem really is -- do I need to fix (and submit a patch for) DBD::RAM or DBD::File?

Current Mood: aggravated
Saturday, August 29th, 2009
1:51 pm
[darth_spacey]
Looking for collaborators
Does anyone here use jEdit, Perl, and Moose.pm?

I'm trying to work on a Moose project, and while jEdit's builtin Perl edit mode and Perl Sidekick are both more than adequate for normal Perl use, the lack of Moose support is starting to get on my nerves. I'm getting closer and closer to breaking down and taking on the workload of making a Moose mode and a Moose Sidekick.

The edit mode should be a simple matter of hacking the extra keywords into a copy of the XML file used for the Perl mode, and I think I'm up to that task all by myself, but the Sidekick is going to take some Java knowhow, and some jEdit API knowhow. Being the lazy layabout that I am, I'm looking for someone to help out.

Any takers?
Sunday, February 8th, 2009
11:08 pm
[skadd4life]
Perl N00b
Hey guys,

I am more a C person, and am having some trouble here.

I have an array, and I want to delete all the characters of a line after a character. I have been using the split command with poor success:

foreach $TextLine (@OutLabText)
{
@Tokens = split("/[[]/", "$TextLine"); #doesnt work at all...
@Tokens = split(/\n/, "$TextLine");
@Tokens = split(/;/, "$TextLine");
}

Is there an easy way to specify "Delete everything after " [ " or ";"?

Thanks!
Thursday, January 8th, 2009
4:56 am
[gangleon]
I have a problem with installing CamelBones in MacOs Leopard (Xcode 3.0).
Download CamelBones 1.0.3, install.

After installing in Xcode must appear perl-project:


But it does not appear.

Who has faced such a problem? What can i do?
Thursday, March 6th, 2008
4:10 pm
[jfroebe]
Has anyone written a perl <=> Yahoo calendar script/app?
I’ve looked on Yahoo, Google, CPAN and on Perlmonks to no avail. I’m wanting to access my Yahoo Calendar from Perl so I can manipulate it, sync it, etc. So far, I’ve only found commercial or shareware applications that can access the calendar. Has anyone done this or know of a non-perl sdk I can look at to write a perl sdk to do it?


Current Mood: frustrated
Friday, November 2nd, 2007
2:51 pm
[patrickwonders]
Idiom question

So, I have lots of perl code that parses XML to a dom using XML::Simple and then tries to iterate over particular tags. When I inherited this code, there were many loops like this:

    if ( $dom->{'foo'} ) {
	foreach my $foo ( @{ $dom->{'foo'} } ) {
	    # blah, blah, blah
	}
    }

Some daringly omitted the if. But, then along came some XML without the <foo> tag and the cron jobs gacked.

I find the whole if-wrapper thing to be distracting from the main-line of the code. I've adopted this idiom instead:

    foreach my $foo ( @{ $dom->{'foo'} || [ ] } ) {
	# blah, blah, blah
    }

...which is what I wish Perl would do for me anyway when I try to coerce undef to an array context.

My question is: is this too obscure or arcane? Is this going to confuse people or will they just say... Ah, it's looping over the foo things and just ignore the rest of the line noise?



Current Mood: curious
Thursday, August 16th, 2007
10:15 am
[chasman]
Does anyone know how to use the sed command to capture the next line in a file?
Friday, July 6th, 2007
11:33 am
[hjsb]
Searching the $PATH for a command
OK, if I want to check a file exists, I use
if ( -f "~/.bashrc" ) { blah ; }

But is there a way to do something similar to see if a command exists in the current path? I.e. to check that if I do
system("my_command");

It will find the command and run it.
Ideally, it would also check aliases, functions, etc, but this is not necessary. I could get the filename using a system(which) call, then check that that is executable, but it seems such a long way round. Any ideas?
Friday, May 18th, 2007
5:05 pm
[jfroebe]
Geek Spotlight: Nicola Worthington

Every once in a while, I'm going to try to highlight an individual that stands out from the rest. Earlier today I was fortunate enough to be able to sit down, virtually, with Perl developer, Nicola Worthington....

Read more...



Current Mood: accomplished
Thursday, May 10th, 2007
6:29 pm
[jfroebe]
O_DIRECT & O_ASYNC, Linux & Perl

I've written a C program that creates a 20GB file using O_DIRECT and O_ASYNC correctly. The trick to write to a file using O_DIRECT is that I have to align the buffer with respect to the memory block size.

When I write a similar program using Perl, I receive the expected "System write error: Invalid argument" as the buffer is not aligned.

So, my question is: Is it possible, in Perl, to align the buffer?

#!/usr/bin/perl use strict; use warnings; $|++; use Fcntl qw(:DEFAULT O_ASYNC O_DIRECT); my $FH; sysopen($FH, "./test.dat", O_WRONLY | O_TRUNC | O_CREAT | O_ASYNC | O_DIRECT, 0666); my $BUFFER = "0"x1048576; my $BUFSIZE = 1048576; for (my $i = 0; $i < 20480; $i++) { my $written = syswrite($FH, $BUFFER, $BUFSIZE); die "System write error: $!\n" unless defined $written; }

Jason L. Froebe

Don't forget Mother's Day! It's this Sunday so get her some sock yarn.



Current Mood: frustrated
Monday, February 26th, 2007
10:09 am
[chasman]
New Perl Programmer
I found some code online that grabs the size of a file. I have tried to modify that code to put the file size into another file called temp1.txt, but I am having trouble.

Could someone help? I know this is an easy issue. I am simply not a perl programmer but am striving to learn.

Thanks!

The Code:

#!/usr/bin/perl
use strict;
use warnings;
use File::stat;

my($caw) = "temp1.txt";
my $filesize = stat("growth_file")->size;

#open(VALUES, $filesize);
#open(VALUES, "temp1.txt");

# Put filesize into temp1.txt file
open(FILESIZE, ">$caw");

print "Size: $filesize\n";

close(FILESIZE);

#close(VALUES);

exit 0;
1:39 am
[ex_beshenov]
uniesc.pl

Useful thing. Can you suggest/correct something?

#!/usr/bin/perl -w

use Getopt::Long;
use utf8;
use encoding utf8;
use charnames qw(:full);

GetOptions ( "format=s" => \$format );

# if ($format eq "Source" || !defined($format))
if ($format eq "Source") { # Escape as \uFFFF
	foreach my $str (<STDIN>) {
		utf8::decode($str);
		foreach (unpack("U*", $str)) {
			if ($_ > 127) {
				printf "\\u%04x", $_;
			}
			else {
				printf chr($_);
			}
		}
	}
}

else {
	if ($format eq "XML") { # Escape as &#xFFFF; (XML entities)
		foreach my $str (<STDIN>) {
			utf8::decode($str);
			foreach (unpack("U*", $str)) {
				if ($_ > 127) {
					printf "&#x%04x;", $_;
				}
				else {
					printf chr($_);
				}
			}
		}
	}

	else {
die "uniesc.pl, the Unicode Escaper
Usage:
	uniesc.pl --format XML
for escaping as &#xFFFF;
or
	uniesc.pl --format Source
for escaping as \\uFFFF

Recommended:
	cat ifile | uniesc.pl [options] > ofile
";
	}

}
1:35 am
[ex_beshenov]
findclones.pl

Useful thing. Can you suggest/correct something?

#!/usr/bin/perl -w

use Getopt::Long;
use File::Find;
use Digest::MD5;
GetOptions ( "dir=s" => \$dir );

my %chcksmtbl;

if (not defined $dir) {
die "findclones.pl, the Clone Finder
Usage:
	findclones.pl --dir=/path/to/certain/directory
";
}

sub checksum {
	my $file = $File::Find::name;
	if (-f and -r and -e and not -z) {
	open(FILE, $file) or print "Can't open '$file': $!\n";
	binmode(FILE);
		$checksum = Digest::MD5->new->addfile(*FILE)->hexdigest;
		if (exists $chcksmtbl{$checksum}) {
			print "$file\tlooks like\t$chcksmtbl{$checksum}\n";
		}
		else {
			$chcksmtbl{$checksum} = $file;
		}
	}
}

find (\&checksum, $dir) or die "Can't open '$dir': $!\n";
Wednesday, February 7th, 2007
12:52 pm
[jfroebe]
An easy way to view maintenance logs using a browser
As part of our regular weekend maintenance for our Sybase database servers, we run many scripts, two of which are: update statistics and reorg/reindex.  In the past, if we wanted to show the output (log) of a maintenance script to someone outside of our group, we had to attach the log to an email and email to the person with instructions to open it using "write" or Microsoft Word and not Notepad because of the way unix/linux and windows handle new lines.  I wanted to get away from this painful ordeal by having the webserver find the logs and display them.  Now we just have to give the url to the person once. Cool

As we use Apache with mod_perl and Mason quite heavily, I decided the easiest way to do this is to create a component to obtain the list of the log files I'm interested in.  When I click on one of the files, instead of accessing the file semi-directly using a symbolic link to the file, a dhandle is called instead.  The dhandle catches the reorg/SISDBA1.out request, goes and reads the real file and spits it out.  If the file is an archived log (compressed), then we uncompress the file as we read it.

Adding a new series of log files are easy because the criteria we search for is a prefix in the filename.  Change the prefix in the index.html file, then the new log files are now viewable.  Of course, you will want to either modify the index.html file to handle multiple types of log files or just create another directory (i.e. dbccs) and copy the index.html & dhandler into it.

Adding a CSS template to this would be a simple matter.  In any case, enjoy!

Source code

Current Mood: accomplished
Wednesday, January 31st, 2007
6:01 am
[ex_beshenov]
Code highlighting

Hi!

I am not a Perl geek and I am using patterns and recipes to cook scripts.

I am trying to do conversion from C / C++ code to the hypertext with style sheets. Actually, it is a code highlighting.

Script below (sorry for huge code citation) does not work.

  1. It is stupid and complex :-)
  2. It highlights special words inside strings.
  3. It 'eats itself' and replacing <span class="keyword"> to <span <span class="keyword">class</span>="keyword"> in some cases!
  4. It can't highlight word at start of line.
  5. It does not highlights something (why?).

Help me to correct it.

Are there good scripts for highlighting code on C / C++ / Java / Perl / Bash / etc.?

Thanks!

Read more...Collapse )
Monday, November 6th, 2006
3:59 pm
[jfroebe]
Problem with filtered Mason code & db connection

Hi,

In chapter 5 (Advanced Features pgs 82,83) of Embedding Perl in HTML with Mason from O'Reilly, the"a simple SQL select expressed in something like a taglib style" example appears to be straight forward.  It is but it doesn't seem to work too well.

The premise is that the ".components/sql/select" will filter the chunk of html code
    <&| .components/sql/select, query => 'SELECT name, type FROM sysobjects' &>
----> here
        <tr>
            <td>%name</td>
            <td>%type</td>
        </tr>
----->to here
     </&>

The select returns data correctly but the ".components/sql/select" doesn't appear to be printing the code hmmmm....  see the very bottom for the answer... I didn't catch it for awhile but later saw the cause and could have kicked myself.

Code & OutputCollapse )

Current Mood: frustrated
[ << Previous 20 ]
About LiveJournal.com