Q:

Write on unblessed reference in perl

Why am i getting an error saying "Can't call method 'write' on unblessed reference at /usr/..."
When i run on my ubuntu there was no error at all but when i run this code on my gentoo.  This error pops out.  I think the OS is not the problem here.  but what is it? 
Here is my code :
#! /usr/bin/perl
#index.cgi

require 'foobar-lib.pl';

ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1);

ui_print_footer("/", $text{'index'});

use CGI;
use Config::Tiny;
use Data::Dumper;
use CGI::Carp qw(fatalsToBrowser);

#location/directory of configuration file
my $file = "/home/admin_config.conf";
my $Config = Config::Tiny->read($file);

#reads the section, key and the value of the configuration file. 
my $status_in_file = $Config->{"offline_online_status"}->{"offline_online_status.offline_online_state"};

print "Content-type:text/html\n\n";

print qq~<html>
<link rel="stylesheet" type="text/css" href="style4.css">
<body>

<div id="content">
<div id="bar">
<span><p>Controller Settings</p></span>
</div>

<div id="tab-container">
<ul> 
<li><span><a href="index.cgi">Offline / Online State</a></span></li>
</ul>

</div>

<div id="main-container">

<table border="0" width="100%" height="80%">
<tr>
<td align="left" width="20%">
<div id="title"><span>Offline/Online Status :</span></div>
</td>
<td width="25%">
<table border="0" style=\"text-align:right;font-family:Arial, Helvetica, sans-serif;\" cellpadding="5">
<tr>
<td width="30%"><div id="data">Offline Online State:</div></td>
</tr>
<tr>
<td width="30%"><div id="data">Data Mode:</div></td>
</tr>
</table>
</td>
<td align="left" width="20%">
<table border="1" style=\"text-align:center;font-family:Arial, Helvetica, sans-serif;\" cellpadding="5">
<tr>
<td width="20%"><div id="data">$status_in_file</div></td>
</tr>
</table>
</td>
<td width="50%"></td>
</tr>
<tr>
<td colspan="4">
<div id="description"><p><b>Description :</b></p>
<p>This <i>indication</i> is sent ..</p>
</div>
</td>
</tr>
</table>

</div>
</div>

</body>
</html>

~;

Can anybody please help me? 
Here is my foobar-lib.pl
=head1 foobar-lib.pl
foreign_require("foobar", "foobar-lib.pl");
@sites = foobar::list_foobar_websites()
=cut
BEGIN { push(@INC, ".."); };
use WebminCore;
init_config();
=head2 get_foobar_config()
=cut
sub get_foobar_config
{
my $lref = &read_file_lines($config{'foobar_conf'});
my @rv;
my $lnum = 0;
foreach my $line (@$lref) {
my ($n, $v) = split(/\s+/, $line, 2);
if ($n) {
push(@rv, { 'name' => $n, 'value' => $v, 'line' => $lnum });
}
$lnum++;
}
return @rv;
} 

i don't really understand about this foobar-lib.pl also.  Maybe this whats caused my problem when i run the codes perhaps? 

A:

The code you've shown doesn't attempt to call a method called write on anything at all, let alone on an unblessed reference.  So I assume the method call happens in some code you haven't shown.  Perhaps in foobar-lib.pl? 
Because I can't see the code causing the error, I can only hazard a guess based on the clue that the method is called write. 
In Perl, it's kind of ambiguous as to whether filehandles classed as "objects" (and can thus have methods called on them), or unblessed references (and thus can't).  The situation changed in Perl 5.12, and again in Perl 5.14.  So if you've got different versions of Perl installed on each machine, then you might observe different behaviours when trying to do:
$fh->write($data, $length)

The Perl 5.14+ behaviour is probably what you want (as it's the most awesome), and luckily you can achieve that same behaviour on earlier versions of Perl by pre-loading a couple of modules.  Add the following two lines to the top of your script:
use IO::Handle ();
use IO::File ();

Problem solved... perhaps???