Description: I've always thought it should be possible to find the size of the special filehandle DATA, but haven't figured out how until now.
my $start_of_DATA = tell(DATA);
my $total_file_size = -s DATA;
my $size_of_DATA = $total_file_size - $start_of_DATA;

### or, you can golf it to this
# my $size_of_DATA = (-s DATA) - tell(DATA);

this is the data
of the program.
woo woo
Replies are listed 'Best First'.
Re: Eureka! size of DATA (modern)
by tye (Sage) on Feb 17, 2006 at 00:37 UTC

    For the old-timers, I'd like to note that this doesn't work for non-byte-stream files. seek/tell positions aren't always byte offsets, though these days it is getting hard to find people who remember working on such systems. :)

    (Also, note that -s doesn't always tell you how many bytes you'll get when you read the file -- the most common case being "\r\n"-to-"\n" translation w/o binmode on Win32.)

    - tye