1#!/usr/local/bin/perl 2 3($iam = $0) =~ s%.*/%%; 4$tmp = "$iam.$$"; 5open (CODE, '>', "$tmp.c") || die "$iam: cannot create $tmp.c: $!\n"; 6 7$mask = q/printf ("$sizeof{'%s'} = %d;\n"/; 8 9# write C program 10select(CODE); 11 12print <<EO_C_PROGRAM; 13#include <sys/param.h> 14#include <sys/types.h> 15#include <sys/socket.h> 16#include <net/if_arp.h> 17#include <net/if.h> 18#include <net/route.h> 19#include <sys/ioctl.h> 20 21main() { 22EO_C_PROGRAM 23 24while ( <> ) { 25 chop; 26 printf "\t%s, \n\t\t\"%s\", sizeof(%s));\n", $mask, $_,$_; 27} 28 29print "\n}\n"; 30 31close CODE; 32 33# compile C program 34 35select(STDOUT); 36 37system "cc $tmp.c -o $tmp"; 38die "couldn't compile $tmp.c" if $?; 39system "./$tmp"; 40die "couldn't run $tmp" if $?; 41 42unlink "$tmp.c", $tmp; 43