SPUG: Parsing (Windows) PE files in Perl

jerry gay jerry.gay at gmail.com
Fri Jan 13 09:00:40 PST 2006


On 1/13/06, David Dyck <david.dyck at fluke.com> wrote:
>
> On Thu, 12 Jan 2006 at 06:56 -0800, jerry gay <jerry.gay at gmail.com> wrote:
>
> > it'll go something like:
> >
> >    my $file = 'foo.dll';
> >    open(local *PE, '>', my $file)
> >        or die qq{can't open $file: $!};
> >    binmode 1;
> >
> >    # read from the file...
> >
> >    close *PE;  # remember to close it when you're done
>
>
> You comment about reading from the file, but doesn't
> the open flag '>' WRITE to the file?
>
that's the danger of coding perl at 6:56am.

my $file = 'foo.dll';
open(local *PE, '<', my $file)
    or die qq{can't open $file: $!};
binmode *PE;

should work much better for reading a file.

on another note, if yitzchak's scalar ref-to-filehandle syntax is
preferred, use that. it works just as well.

~jerry


More information about the spug-list mailing list