in reply to Combining modules into a single file

Just stoking the fire here... I have tried something similar to this, several ways!

Inserting your module code at the beginning is cool, but I found it aesthetically displeasing - and a nuisance to scroll through to get to the few lines of main code. I can't find the code anymore (blush) , but here's how I remember doing it, slurping everything in __DATA__ then an eval on that. No doubt other monks will be able to explain the pitfalls in doing this.. but it werked 4 me!!

#!/usr/bin/perl -w use strict; my @code = <DATA>; my $code = join "" , @code; eval $code; my $stuff = Foo->new('RedCar'); print $stuff->{bar}; __DATA__ package Foo; sub new { my $self= shift; my $val = shift; my %hash =( bar=> $val);; return bless { %hash}, $self; }