Error: Variable "%userdata" is not imported at library.pl line 242.
Here is the code:
sub some_sub {
require 'wpconfig.cgi';
tie(%config, 'tie::config');
tie(%userdata, 'tie::config');
}
package tie::config;
@ISA = qw(Tie::StdHash);
use strict;
sub STORE {
my $self = shift;
$self->SUPER::STORE(@_);
saveConfig();
}
# saveConfig: This is what actually saves wpconfig.cgi.
sub saveConfig {
my $fh = main::open '>wpconfig.cgi';
print $fh "# DO NOT MODIFY THIS FILE\n# IT IS GENERATED DYNAMICALL
+Y!!\n\n";
print {$fh} main::genHash(config); # genHash just takes the hash a
+nd generated perl code for it.
print {$fh} main::genHash(userdata);
print $fh "\n1;";
close $fh;
}
package main;
# exit: Exits and unties %config and %userdata.
sub exit {
untie(%config) if %config;
untie(%userdata) if %userdata; # <- line 242
CORE::exit();
}
This works fine (not errors) but it won't update the file.sub some_sub {
require 'wpconfig.cgi';
tie(%config, 'tie::config');
tie(%userdata, 'tie::config');
}
package tie::config;
sub TIEHASH {}
sub STORE {
my $self = shift;
$self->SUPER::STORE(@_);
saveConfig();
}
# saveConfig: This is what actually saves wpconfig.cgi.
sub saveConfig {
my $fh = main::open '>wpconfig.cgi';
print $fh "# DO NOT MODIFY THIS FILE\n# IT IS GENERATED DYNAMICALL
+Y!!\n\n";
print {$fh} main::genHash(config);
print {$fh} main::genHash(userdata);
print $fh "\n1;";
close $fh;
}
package main;
# exit: Exits and unties %config and %userdata.
sub exit {
untie(%config) if %config;
untie(%userdata) if %userdata;
CORE::exit();
}
|