Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/h2pl/mkvars

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/usr/bin/perl

require 'sizeof.ph';

$LIB = '/usr/local/lib/perl';

foreach $include (@ARGV) {
    printf STDERR "including %s\n", $include;
    do $include;
    warn "sourcing $include: $@\n" if ($@);
    if (!open (INCLUDE,"$LIB/$include")) {
	warn "can't open $LIB/$include: $!\n"; 
	next; 
    } 
    while (<INCLUDE>) {
	chop;
	if (/^\s*eval\s+'sub\s+(\w+)\s.*[^{]$/ || /^\s*sub\s+(\w+)\s.*[^{]$/) {
	    $var = $1;
	    $val = eval "&$var;";
	    if ($@) {
		warn "$@: $_";
		print <<EOT;
warn "\$$var isn't correctly set" if defined \$_main{'$var'};
EOT
		next;
	    } 
	    ( $nval = sprintf ("%x",$val ) ) =~ tr/a-z/A-Z/;
	    printf "\$%s = 0x%s;\n", $var, $nval;
	} 
    }
} 

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.