BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
In the following code taken from exetype.pl,
if you run it with the print "$offset\n" commented out, (against the wperl.exe from the 5.12.0 build), then you get this error:# read IMAGE_DOS_HEADER structure read EXE, $record, 64; ($magic,$offset) = unpack "Sx58L", $record; #print "$offset\n"; die "$ARGV[0] is not an MSDOS executable file.\n" unless $magic == 0x5a4d; # "MZ" # read signature, IMAGE_FILE_HEADER and first WORD of IMAGE_OPTIONAL_H +EADER seek EXE, $offset, 0; read EXE, $record, 4+20+2; ($signature,$size,$magic) = unpack "Lx16Sx2S", $record; ### Line +39
perl-5.12.0\win32>..\miniperl.exe -I..\lib \perl64\bin\exetype.pl ..\w +perl.exe 'x' outside of string in unpack at \perl64\bin\exetype.pl line 39.
which comes down to that the read on line 38 has failed to read enough (26) chars. Probably, because the preceding seek has gone to the wrong place.
But, if you uncomment the print "$offset\n"; line to work out where the seek is going, you get this error:
perl-5.12.0\win32>..\miniperl.exe -I..\lib \perl64\bin\exetype.pl ..\w +perl.exe 240 Use of uninitialized value $subsys in hash element at \perl64\bin\exet +ype.pl line 52. Use of uninitialized value $subsys in concatenation (.) or string at \ +perl64\bin\exetype.pl line 52. ..\wperl.exe uses the UNKNOWN() subsystem.
which means that the seek & read have now succeeded. Just because you printed the value of $offset.
Thoughts? A bug in miniperl.exe?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Here's strange for you!
by almut (Canon) on Apr 13, 2010 at 17:10 UTC | |
by BrowserUk (Patriarch) on Apr 13, 2010 at 17:29 UTC | |
by ikegami (Patriarch) on Apr 13, 2010 at 18:05 UTC |