#!/usr/bin/perl

$/ = "\0";

@files = glob("*en-US.res");

foreach $source_res(@files) {
    open (SOURCE,$source_res) or die ("couldn't open $source_res\n");
    print "\n$source_res\n\n";

    # Last dword contains the number of resources
    seek (SOURCE,-4,2) ;
    read (SOURCE,$stuff,4) ;
    $numitems = (unpack("N",$stuff) - 16) / 12;
    # parsing index
    seek (SOURCE, -$numitems*12-12,2);
    read (SOURCE,$indexheader,8);
    for ($i=0;$i<$numitems;$i++) {
        read (SOURCE,$stuff,12);
        @indexelem = unpack("NNN",$stuff);
        ($type, $id, $offset) = @indexelem;
        printf ("%d\n" , $id);
    }
}
exit 0;
