Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

rjbs (4671)

  (email not shown publicly)
AOL IM: RicardoJBSignes (Add Buddy, Send Message)
Yahoo! ID: RicardoSignes (Add User, Send Message)

I'm a Perl coder living in Bethlehem, PA and working Philadelphia. I'm a philosopher and theologan by training, but I was shocked to learn upon my graduation that these skills don't have many associated careers. Now I write code.

Journal of rjbs (4671)

Thursday October 16, 2008
09:19 PM

annoying things learned about perl today

[ #37681 ]

App::Cmd::Tester lets you test that an App::Cmd program output the right things to standard error and standard out, and did so in the right order. It does stuff Test::Output can do, but also just a bit more.

I had a need to generalize this earlier today, and ran into a bunch of obnoxious problems. Most of these center around the "it's hard to get synchronized but separate output from a spawned program's stderr and stdout" problem. Others were less well-known, at least to me.

For example, I was doing something like this:

tie my $scalar, 'Tie::Class', { common => \$string, private => \$other };

I had a number of things like this, and I thought I'd be able to write:

tie my $scalar, $object->tie_args;

This didn't work, though, because the tie_args method gets called in scalar context, so it evaluated to the hash reference, which of course had no TIESCALAR method.

Instead, I ended up doing something possibly better anyway:

tie my $scalar, $object, $argument;

The object has a TIESCALAR method that proxies to the correct class with the correct arguments. I'm pretty happy with that.

The other problem is this:

tie my $scalar, 'Some::Tie';
open my $fh, '>', \$scalar or die "failed to open ref: $!";
print $fh "this is a test" or die "failed to print: $!;

This code just doesn't do what I mean. It doesn't raise any exceptions, but the STORE method is never called on the tie. This seems, to me, like a bug in perl. I'll need to investigate.

The code I was working on has been uploaded as IO::TieCombine.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.