in reply to How can I catch a Server message displayed in Sybase::CTlib module
You could redirect STDERR for the time you make calls into that module.
package Foo; sub foo { warn "blorf!" } 1;
#!/usr/bin/perl use Foo; use strict; use warnings; sub call (&); call { Foo::foo(); }; if ($@) { warn "foo reported: '$@'\n"; } ## subs # sub call (&) { my $coderef = shift; my $message; open my $fh , '>&', \*STDERR; close STDERR; open STDERR, '>', \$message; $coderef->(); open STDERR, ">&", $fh; $@ = $message; } __END__ foo reported: 'blorf! at Foo.pm line 3. '
That way all you have to do is wrap the places where you call into Sybase::CTlib into a block and dispatch that to the call() function.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I catch a Server message displayed in Sybase::CTlib module
by goutam_monk (Initiate) on May 07, 2009 at 12:15 UTC | |
by Anonymous Monk on May 07, 2009 at 12:24 UTC |