On Mon, 2011-05-30 at 17:47 -0400, Uri Guttman wrote:
>  my %conf = read_file( $file_name ) =~ /^(\w+)=(.*)$/mg ;
> 
> that is an assigment to hash, scalar context call on read_file and a
> regex getting out key=val lines. all stuff newbies need to know and must
> learn. it happens to use them all in one basic line. it is all a very
> teachable thing to anyone who knows what a hash, sub call and regex
> are. i don't expect newbies to know how to read that line but i do
> expect them to able to learn from it. that is what proper training is
> about. not feeding pablum to kiddies.

Bear in mind the original brief:

On Mon, 2011-05-30 at 11:40 +0100, Leo Lapworth wrote:
> I'm working on http://learn.perl.org/ and I'd like to have a few
> rotating examples of what can be done with Perl on the home page.
> [...]
> one liners are fine as long as it is simple to see what they do.

So these aren't lessons - they're standalone code samples.  If it needs
explaining it's probably too complicated.

The Config::Any version of the read is:

use Config::Any;
my $config = Config::Any->load_files( { files => \@files } );

That's immediately readable and understandable, and it will load a
config file (or files) written in almost any standard config-file
format, rather than just key=val files.  It doesn't teach people about
all the raw Perl stuff your example uses, but as a standalone "ooh, look
how easy it is to get stuff done in Perl" it's probably more suitable
for the target audience and intended use-case.

Regards,
Denny

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to