[Android Q&A, Help & Troubleshooting] KainXSS:
I'm trying to build a kernel for my y301-a2 but I get a perl error, i fixed most of the errors but this one keeps coming back

readline() on closed filehandle FXML at parse_product_id.pl on line 19

this is the file in question

#!/usr/bin/perl -w

sub back_trim
{
my $slash_pos = rindex($_[0], $_[1]);
return substr($_[0], 0, $slash_pos);
}

#open ARGV[1]
open FXML, "<$ARGV[0]" || die "can't open $ARGV[0]! please check your command and filesystem.";
open FOUT, ">config_total_product.c" || die "can't open config_total_product.c";
open FBOARDIDS, ">../../../include/hsad/config_boardids.h" || die "can't open board ids header file";

my $max_board_id0 =0;
my $max_board_id1 =0;
my %products;
my $xml_path;

while(<FXML>)
{
chomp;
# only match once: <products max_board_id0="6" max_board_id1="6">
if ($max_board_id0 == 0 && /^\s*<products\s+max_board_id0\s*=\s*\"(\d+)\"\s+max_board_id1\s*=\s*\"(\d+)\"\s*>\s*$/i)
{
$max_board_id0=$1;
$max_board_id1=$2;
}
# <product board_id0="$1" board_id1="$2">product_name</product>
if (/^\s*<product\s+board_id0\s*=\s*\"(\d+)\"\s+board_id1\s*=\s*\"(\d+)\"\s*>(\w+)<\/product>\s*$/i)
{
$board_id0=$1;
$board_id1=$2;
$product_name=$3;
if ($max_board_id1 < 16)
{
$board_id_key = $board_id0 * 16 + $board_id1;
}
else
{
$board_id_key = $board_id0 * ($max_board_id1+1) + $board_id1;
}
$products{$board_id_key} = $product_name;
}
}
close FXML;

$xml_path = &back_trim($ARGV[0], "/");
$xml_path = $xml_path."/";

#generate every product configs
foreach $product (values %products) {
system("perl parse_product.pl ".$xml_path.$product."/kernel/hw_".$product."_configs.xml");
}

#now we got a hash table contain all the product name; then we can print the target file.
select FOUT;
print "/* This file is auto-generated by tool, please don't manully modify it.*/\n\n";

#print board id definition
#foreach $board_id (keys %products) {
# print "#define BOARD_ID_".uc($products{$board_id})." ".$board_id."\n";
#}

#print board id header file includes
print "#include <hsad/config_boardids.h>\n\n";

#retrive the product names in hash table, include them all.
foreach $product (values %products) {
print "#include \"hw_".$product."_configs.c\"\n";
}
print "#ifdef CONFIG_HW_POWER_TREE\n";
foreach $product (values %products) {
print "extern struct board_id_general_struct config_power_".$product.";\n";
}
print "#endif\n";
#generate gpio data
print "\n/*gpio perl producted data*/\n";
print "#ifdef CONFIG_HUAWEI_GPIO_UNITE\n";
foreach $product (values %products) {
print "extern struct board_id_general_struct config_gpio_".$product.";\n";
print "extern struct board_id_general_struct config_pm_gpio_".$product.";\n";

}
print "#endif\n";
print "\n";
#generate total config data, ATTENTION: if you want to add new data structure in hsad, also also data here:
print "/*total table*/\n";
print "struct board_id_general_struct *hw_ver_total_configs[] = \n";
print "{\n";
my $indent = " ";
#part 1: gpio data:
print "#ifdef CONFIG_HUAWEI_GPIO_UNITE\n";
foreach $product (values %products) {
print $indent."&config_gpio_".$product.", //gpio\n";
}
print "#endif\n";
print "#ifdef CONFIG_HUAWEI_GPIO_UNITE\n";
foreach $product (values %products) {
print $indent."&config_pm_gpio_".$product.", //pm gpio\n";
}
print "#endif\n";
#part 2: common data:
foreach $product (values %products) {
print $indent."&config_common_".$product.", //common xml\n";
}
print "#ifdef CONFIG_HW_POWER_TREE\n";
foreach $product (values %products) {
print $indent."&config_power_".$product.",\n";
}
print "#endif\n";
print "};\n";

close FOUT;

#output board ids to include/hsad/config_boardids.h
select FBOARDIDS;
print "/* This file is auto-generated by tool, DO NOT modify it manully. */\n\n";
print "#ifndef CONFIG_BOARDIDS_H\n";
print "#define CONFIG_BOARDIDS_H\n\n";
foreach $board_id (keys %products) {
print "#define BOARD_ID_".uc($products{$board_id})." ".$board_id."\n";
}
print "\n";
print "#endif\n";

anyone have any idea what could be causing it.