Michael Lazzaro asked:

OK, next question.  Is _THIS_ possible?

   class FileBasedHash is Hash { ...stuff... };

   my %data is FileBasedHash('/tmp/foo.txt');
Yes. Though we would need a syntax for specifying that string parameter for the
generic C<FileBasedHash> class. And, of course, a mechanism for constructing the
non-generic version of the generic class from the corresponding argument.


And if _that's_ possible, is _THIS_ possible?

   my $path = '/tmp/foo.txt';
   my %data is FileBasedHash($path);
Indeed. In fact, there may even be a standard property that does this kind of
thing:

      # Note: this is purely speculative...

      my $str is from($filename);     # text in file becomes chars in string

      my @lines is from($filename);   # lines in file become elements in array

      my %config is from($filename);  # colon-separated fields in file become kv pairs in hash

Damian





Reply via email to