in reply to Size of scalar in bytes

Is there an easy way to tell the size of a scalar (preferably in bytes)?

use bytes; my $len = length $var;

And while I'm thinking of it, if I go grab a file over HTTP using LWP::UserAgent, is there an easy way to tell the size of what I downloaded?

Servers should (but aren't required) to send a Content-Length header. If the server didn't send it, then there isn't a way you can tell the size until you've already downloaded it. Most servers will send that header, but you should code in such a way that it gracefully handles the lack of Content-Length.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated