[ic] include GlobalSub in interchange.cfg

Honest to Goodness interchange-users@interchange.redhat.com
Mon Apr 1 13:14:00 2002


This caused a big nasty crash. The browser showed an internal server
error, and the ic error log had this to say:

127.0.0.1 t5AIAYYA:127.0.0.1 - [01/April/2002:13:00:52 -0500] foundation
/cgi-bin/foundation/aboutus.html Runtime error: Unable to create sub
named "" at /usr/lib/interchange/lib/Vend/Interpolate.pm line 2452.

The line from Interpolate.pm does indeed deal with all of this. It is:

*$_ = \&{$Global::GlobalSub->{$_}};

Which looks like an appropriate place to break. It seems that the whole
GlobalSub failed. Here is my structure:

GlobalSub <<EOS

sub canpost {
use IO::Socket;

my $server = '206.191.4.228';
my $port = 30000;

my @out = '<?xml version="1.0" ?>';
...
my $sock = IO::Socket::INET->new(
  Proto  => "tcp",
  PeerAddr => $server,
  PeerPort => $port,
  Reuse => 1
  );
 unless ($sock) { return("cannot connect to post host"); }
 $sock->autoflush(1);

 foreach $line (@out) {
   print $sock "$line\n";
 }
@out = '';
 yup: while ( <$sock> ) {
    last yup if (/END_OF_EPARCEL/);
    push (@out, $_);
}
 close $sock;
 return("@out");
}
EOS

With use placed inside the sub I get an unloaded module error. Placed
outside the sub and the whole module fails to be defined.



On Mon, 2002-04-01 at 12:43, Ed LaFrance wrote:
> At 12:24 PM 04/01/2002 -0500, you wrote:
> >I tried that. When I use IO::Socket::INET it works fine in a stand alone
> >perl program but breaks when run as a GlobalSub. Somehow ic is being
> >blocked from loading the module.
> >
> >I don't know how to ask Perl if a module is installed but since it
> >compiles and runs OK I have some strong evidence that it is there.
> 
> I don't know how you have structured your code, since you never posted it, 
> but try your 'use' statement outside of the sub {} body if it is not 
> already that way, i.e.:
> 
> GlobalSub <<EOS
> use IO::Socket::INET;
> sub {
>          ...
> }
> EOS
> 
> 
> 
> - Ed L.
> 
> 
> 
> 
> 
> 
> >On Mon, 2002-04-01 at 12:01, Kevin Walsh wrote:
> > > >
> > > > My GlobalSub opens a socket to talk to another server. I have tested
> > > > this as a perl program from my command line where it works fine. Here is
> > > > part of the code:
> > > >
> > > > use IO::Socket;
> > > > my $server = '206.191.4.228';
> > > > my $port = 30000;
> > > >
> > > > my $sock = IO::Socket::INET->new(
> > > >   Proto  => "tcp",
> > > >   PeerAddr => $server,
> > > >   PeerPort => $port,
> > > >   Reuse => 1
> > > >   );
> > > >  unless ($sock) { return("cannot connect to remote host"); }
> > > >
> > > > But when I try to run this through ic I get this error message:
> > > >
> > > > 127.0.0.1 uthu8k6e:127.0.0.1 - [31/March/2002:23:48:00 -0500] foundation
> > > > /cgi-bin/foundation/aboutus.html Safe: Can't locate object method "new"
> > > > via package "IO::Socket::INET" (perhaps you forgot to load
> > > > "IO::Socket::INET"?) at (eval 128) line 34.
> > > >
> > > You might want to try installing the IO::Socket::INET module.
> > > If its already installed "use IO::Socket::INET;" may help.