[Unix Solaris11] RPM2PKG error about compilation.

Hi,
I'm new on this forum. I'm working on Solaris 11 (Express Edition) and I must install some programm created only for RedHat system (I don't want to buy or download RedHat). So I search for this tools and I find a working script for Solaris 9 and 10, but I need that for Solaris 11. So I search the difference between them and I modify the script, but it doesn't work.
I post here the code of the script:

#!/usr/bin/perl
#
# rpm2pkg - creating Solaris pkg files from Linux rpm's
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

$rpm=$ARGV[0];
$tmp_dir="dir.$$";
$orig_dir=`pwd`;

mkdir("$tmp_dir");
chdir("$tmp_dir");
system("rpm2cpio ../$rpm|cpio -dim");
$proto_list=`find . -print|/bin/pkgproto|grep -v prototype`;
open(TMP_FILE, ">>prototype");
print TMP_FILE "i pkg info\n";
print TMP_FILE $proto_list;
close(TMP_FILE);
@pkg_info=`strings ../$rpm`;
$count = 0;
foreach (@pkg_info)     {
        if ( $_ =~ /\# \@\(\#\)BegWS/ ) {
                push(@rpm_info, $_);
                $count++;
        }       elsif ( $_ =~ /\# \@\(\#\)EndWS/ )      {
                last;
        }       elsif ( $count > 0 )    {
                push(@rpm_info, $_);
        }
}
$uname_s = `uname -s`;
$uname_r = `uname -r`;
$uname_p = `uname -p`;
$pkg_name = $rpm;
$pkg_name =~ s/\.rpm//;
chomp $uname_s;
chomp $uname_r;
chomp $uname_p;
chomp $rpm_info[1];
chomp $rpm_info[2];
chomp $rpm_info[5];
chomp $rpm_info[12];
open(PKGINFO, ">>pkginfo");
print PKGINFO "SUNW_PRODNAME=\"$uname_s\"\n";
print PKGINFO "SUNW_PRODVERS=\"$uname_r\"\n";
print PKGINFO "SUNW_PKGTYPE=\"usr\"\n";
print PKGINFO "PKG=\"$pkg_name\"\n";
print PKGINFO "NAME=\"$rpm_info[2]\"\n";
print PKGINFO "VERSION=\"$rpm_info[5]\"\n";
print PKGINFO "VENDOR=\"$rpm_info[1]\"\n";
print PKGINFO "ARCH=\"$uname_p\"\n";
print PKGINFO "EMAIL=\"me@xyz.com\"\n";
print PKGINFO "CATEGORY=\"application\"\n";
print PKGINFO "BASEDIR=/\n";
print PKGINFO "DESC=\"$rpm_info[12]\"\n";
print PKGINFO "PSTAMP=\"Your Name Here\"\n";
print PKGINFO "CLASSES=\"none\"\n";
close(PKGINFO);
system("/bin/pkgmk -o -b `pwd` -d /tmp");
system("/bin/pkgtrans -o -s /tmp `pwd`/test01.pkg test01");
system("mv test01.pkg ../");
system("cd ../;pwd;rm -r $tmp_dir");

The error is this:

## Building pkgmap from package prototype file.
ERROR in prototype:
    garbled entry
    - pathname: pkg
    - problem: extra tokens on input line
pkgmk: ERROR: unable to build pkgmap from prototype file
## Packaging was not successful.
pkgtrans: ERROR: unable to complete package transfer
    - no packages were selected from </tmp>
mv: cannot access test01.pkg
/root

If I cut the program to "close(PKGINFO);" It will work.
If anyone can help me I will release this script on this topic =)

Thank's for all.

(sorry for my not perfect english)

Can you paste the contents of the pkginfo file that the script generates?