Re: Cool/useful short examples of Perl?

2011-05-30 Thread Leo Lapworth
Hi, Thanks to those who provided me examples. I'm glad everyone else has had interesting discussions, it's obvious that lots of people have opinions.. which is nice, though I'm not looking to get into discussions, I'm focusing on building a website. For those interested learn.perl.org is going t

try something different

2011-05-30 Thread Uri Guttman
instead of showing random perl examples on learn.perl why not highlight the good docs that already exist. the other day someone asked on irc about some ref stuff and i pointed them to perlreftut. the tutes are full of useful stuff but they aren't read by newbies (i know that from many times tellin

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Gabor Szabo
On Tue, May 31, 2011 at 2:23 AM, Paul Makepeace wrote: > On Mon, May 30, 2011 at 23:20, lesleyb wrote: >> I had previous programming experience when I started learning Perl >> and I was quickly introduced to the 'unless' construct.  I confess >> to finding it both cute and entirely obvious. > > Y

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Avleen Vig
On Mon, May 30, 2011 at 7:45 PM, Damian Conway wrote: > I'll happily concede that this example isn't nearly as impressive as > some of the others in this thread, but its real-world, useful, > conveniently incremental, requires no modules, and ably > demonstrates the value of many core features of

Re: ActiveMQ (was Re: Devel::Cover with Moose?)

2011-05-30 Thread Toby Wintermute
On 27 May 2011 02:58, David Cantrell wrote: > On Thu, May 26, 2011 at 05:25:01PM +0100, Simon Wistow wrote: > >> Unless things have changed dramatically ActiveMQ has many, many features >> pretty much all poorly documented in the typical ASF/Java project >> fashion (i.e a poorly maintained wiki re

Re: Cool/useful short examples of Perl?

2011-05-30 Thread 'lesleyb'
On Mon, May 30, 2011 at 07:46:08PM -0400, Uri Guttman wrote: > > "NC" == Nicholas Clark writes: > > > NC> You've stated that you *don't* expect newbies to know how to read > NC> that line. Leo is currently looking for things that newbies could > NC> be expected to read. > > then you

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Damian Conway
Uri wrote: > ever taken a class with damian? he doesn't pussy foot around with > kiddie code. that line is just like stuff he trains with No it isn't. Not in my beginners classes, nor in PBP. When I'm teaching newcomers to Perl, I focus my examples entirely on readability and maintainability. Fo

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "NC" == Nicholas Clark writes: NC> You've stated that you *don't* expect newbies to know how to read NC> that line. Leo is currently looking for things that newbies could NC> be expected to read. then you will get one liners that don't do much. you can't have it both ways. either t

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Paul Makepeace
On Mon, May 30, 2011 at 11:40, Leo Lapworth wrote: > I'm working on http://learn.perl.org/ and I'd like to have a few rotating > example of what can be done with Perl on the home page. I think this is great, curl -L http://cpanmin.us | perl - --sudo App::cpanminus An installer that installs

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Paul Makepeace
On Mon, May 30, 2011 at 23:20, lesleyb wrote: > I had previous programming experience when I started learning Perl > and I was quickly introduced to the 'unless' construct.  I confess > to finding it both cute and entirely obvious. Yeah, seriously. You know, if someone can understand a regular ex

Re: Cool/useful short examples of Perl?

2011-05-30 Thread 'lesleyb'
On Mon, May 30, 2011 at 04:40:26PM -0500, Avleen Vig wrote: > On Mon, May 30, 2011 at 1:35 PM, Jason Clifford wrote: > > On Mon, 2011-05-30 at 16:27 +0100, Denny wrote: > >> >     if (! Email::Valid->address($email_address) ) { > >> > >> Something wrong with 'unless'? > > > > No but lots of people

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Denny
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

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Nicholas Clark
t is simple to see what they do. http://london.pm.org/pipermail/london.pm/Week-of-Mon-20110530/020713.html You've stated that you *don't* expect newbies to know how to read that line. Leo is currently looking for things that newbies could be expected to read. Nicholas Clark

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "DH" == Dave Hodgkinson writes: DH> On 30 May 2011, at 22:47, Uri Guttman wrote: >>> "DH" == Dave Hodgkinson writes: >> DH> And MAINTAINABLE. >> DH> Not everyone speaks line noise. >> >> if you think that is line noise, then your perl skills need >> improving.

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Avleen Vig
On Mon, May 30, 2011 at 4:47 PM, Uri Guttman wrote: > if you think that is line noise, then your perl skills need > improving. seriously i have taught the slurp line to total beginners and > they get it afterwards. this is for learn.perl.org, not golf. > >  my %conf = read_file( $file_name ) =~ /^

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 22:47, Uri Guttman wrote: >> "DH" == Dave Hodgkinson writes: > > DH> And MAINTAINABLE. > > DH> Not everyone speaks line noise. > > if you think that is line noise, then your perl skills need > improving. And this is EXACTLY the problem. If this is perl, then we've l

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Avleen Vig
On Mon, May 30, 2011 at 3:02 PM, Uri Guttman wrote: >> "D" == Denny  <2...@denny.me> writes: > you need to challenge them a bit with new stuff instead of > handing them simple code anyone can do. It depends entirely. If we're teaching things to people who already know some perl, then sure you

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "DH" == Dave Hodgkinson writes: DH> On 30 May 2011, at 22:17, Uri Guttman wrote: >> DH> No. Real people want to solve real world problems in a simple, DH> maintainable way, not wave around a canapé sized penis. >> >> you have a strange way of measuring genitals. real world cod

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Avleen Vig
On Mon, May 30, 2011 at 1:35 PM, Jason Clifford wrote: > On Mon, 2011-05-30 at 16:27 +0100, Denny wrote: >> >     if (! Email::Valid->address($email_address) ) { >> >> Something wrong with 'unless'? > > No but lots of people appear to find "if" to be more readable > > If you're not worried about r

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 22:17, Uri Guttman wrote: > > DH> No. Real people want to solve real world problems in a simple, > DH> maintainable way, not wave around a canapé sized penis. > > you have a strange way of measuring genitals. real world code is also > concise and fast and usable. And MAINTA

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "DH" == Dave Hodgkinson writes: DH> On 30 May 2011, at 21:02, Uri Guttman wrote: DH> you need to challenge them a bit with new stuff instead of >> handing them simple code anyone can do. DH> No. Real people want to solve real world problems in a simple, DH> maintainable way,

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 21:02, Uri Guttman wrote: >> "D" == Denny <2...@denny.me> writes: > > D> On Mon, 2011-05-30 at 13:10 -0400, Uri Guttman wrote: >>> if you think those are complex, you haven't seen enough perl! :) > > D> I'm trying to think about the target audience, rather than show ho

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 21:02, Uri Guttman wrote: you need to challenge them a bit with new stuff instead of > handing them simple code anyone can do. No. Real people want to solve real world problems in a simple, maintainable way, not wave around a canapé sized penis.

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Gabor Szabo
Another example you can add maybe after some further tweaking: #!/usr/bin/env perl use Dancer; get '/' => sub { "Hello World!" }; dance; $ perl bin/app.pl & ... $ curl http://localhost:3000/ Hello world! >From http://perldancer

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "D" == Denny <2...@denny.me> writes: D> On Mon, 2011-05-30 at 13:10 -0400, Uri Guttman wrote: >> if you think those are complex, you haven't seen enough perl! :) D> I'm trying to think about the target audience, rather than show how D> clever I am. that isn't clever in my book. th

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "PN" == Philip Newton writes: PN> On Mon, May 30, 2011 at 17:59, Uri Guttman wrote: >> >> # Here is a simple and fast way to load and save a simple config file >> # made of key=value lines. >> >>  my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ; >>  write_file( $fi

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 19:47, Philip Newton wrote: > On Mon, May 30, 2011 at 17:59, Uri Guttman wrote: >> >> # Here is a simple and fast way to load and save a simple config file >> # made of key=value lines. >> >> my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ; >> write_file( $file_na

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Denny
On Mon, 2011-05-30 at 19:35 +0100, Jason Clifford wrote: > On Mon, 2011-05-30 at 16:27 +0100, Denny wrote: > > > if (! Email::Valid->address($email_address) ) { > > > > Something wrong with 'unless'? > > No but lots of people appear to find "if" to be more readable It's not a choice between

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Philip Newton
On Mon, May 30, 2011 at 17:59, Uri Guttman wrote: > > # Here is a simple and fast way to load and save a simple config file > # made of key=value lines. > >  my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ; >  write_file( $file_name, {atomic => 1}, map "$_=$conf{$_}\n", keys %conf ; I wo

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Jason Clifford
On Mon, 2011-05-30 at 16:27 +0100, Denny wrote: > > if (! Email::Valid->address($email_address) ) { > > Something wrong with 'unless'? No but lots of people appear to find "if" to be more readable If you're not worried about readability then why bother with either the if or unless. Just do:

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Paul Makepeace
On Mon, May 30, 2011 at 14:12, Gabor Szabo wrote: > use Spreadsheet::Read; > > my $ref = ReadData ("test.xls"); > say $ref->[1]{A3}; > > http://search.cpan.org/dist/Spreadsheet-Read/Read.pm Cool module. If you do include it, s/ref/workbook/ Paul (who is puzzled by this name-your-var-with-only-it

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Denny
On Mon, 2011-05-30 at 13:10 -0400, Uri Guttman wrote: > if you think those are complex, you haven't seen enough perl! :) I'm trying to think about the target audience, rather than show how clever I am. signature.asc Description: This is a digitally signed message part

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
> "D" == Denny <2...@denny.me> writes: D> On Mon, 2011-05-30 at 11:59 -0400, Uri Guttman wrote: >> from the File::Slurp synopsis. can't get much cooler, short or useful >> than this. :) >> my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ; >> write_file( $file_name, {atomic =

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Denny
On Mon, 2011-05-30 at 17:30 +0100, David Precious wrote: > On Monday 30 May 2011 16:27:30 Denny wrote: > > On Mon, 2011-05-30 at 15:36 +0100, David Precious wrote: > > > if (! Email::Valid->address($email_address) ) { > > > > Something wrong with 'unless'? > > we're talking bits of code for p

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 16:59, Uri Guttman wrote: > > from the File::Slurp synopsis. can't get much cooler, short or useful > than this. :) > > > # Here is a simple and fast way to load and save a simple config file > # made of key=value lines. > > my %conf = read_file( $file_name ) =~ /^(\w+)=(\

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 16:27, Denny wrote: > On Mon, 2011-05-30 at 15:36 +0100, David Precious wrote: >>if (! Email::Valid->address($email_address) ) { > > Something wrong with 'unless'? > Ask Damian. I also agree, it's a speedbump for my reading. KISS etc.

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Ben Tisdall
Config::Tiny fits the bill nicely. On Mon, May 30, 2011 at 5:13 PM, Denny <2...@denny.me> wrote: > On Mon, 2011-05-30 at 11:59 -0400, Uri Guttman wrote: >> from the File::Slurp synopsis. can't get much cooler, short or useful >> than this. :) >>   my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*

Re: Cool/useful short examples of Perl?

2011-05-30 Thread David Precious
On Monday 30 May 2011 16:27:30 Denny wrote: > On Mon, 2011-05-30 at 15:36 +0100, David Precious wrote: > > if (! Email::Valid->address($email_address) ) { > > Something wrong with 'unless'? Depends whether you follow Damian Conway's PBP strictly :) At $work, we mostly do follow PBP, but with

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Denny
On Mon, 2011-05-30 at 11:59 -0400, Uri Guttman wrote: > from the File::Slurp synopsis. can't get much cooler, short or useful > than this. :) > my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ; > write_file( $file_name, {atomic => 1}, map "$_=$conf{$_}\n", keys %conf ; It's kind of hor

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Uri Guttman
from the File::Slurp synopsis. can't get much cooler, short or useful than this. :) # Here is a simple and fast way to load and save a simple config file # made of key=value lines. my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ; write_file( $file_name, {atomic => 1}, map "$_=$conf

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Pedro Figueiredo
Something I use quite a lot when skimming through log files: perl -le 'print scalar localtime shift' Ok, probably less than you were looking for... Cheers, Pedro

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Denny
On Mon, 2011-05-30 at 15:36 +0100, David Precious wrote: > if (! Email::Valid->address($email_address) ) { Something wrong with 'unless'? signature.asc Description: This is a digitally signed message part

Re: Cool/useful short examples of Perl?

2011-05-30 Thread 'lesleyb'
On Mon, May 30, 2011 at 03:36:54PM +0100, David Precious wrote: > On Monday 30 May 2011 14:27:25 'lesleyb' wrote: > > I am a little fearful people will substitute variables on the > > RHS in a CGI script without untainting first and then complain > > when the problems show up. > > Whilst I agree

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Dave Hodgkinson
On 30 May 2011, at 11:40, Leo Lapworth wrote: > Hi, > > I'm working on http://learn.perl.org/ and I'd like to have a few rotating > example of what can be done with Perl on the home page. Like this concept. Some idioms based around some of the major modules would be nice. Especially, bit not l

Re: Cool/useful short examples of Perl?

2011-05-30 Thread David Precious
On Monday 30 May 2011 14:27:25 'lesleyb' wrote: > I am a little fearful people will substitute variables on the > RHS in a CGI script without untainting first and then complain > when the problems show up. Whilst I agree helping people learn about taint mode and how to untaint is valuable, I'm

Re: Cool/useful short examples of Perl?

2011-05-30 Thread 'lesleyb'
On Mon, May 30, 2011 at 11:40:57AM +0100, Leo Lapworth wrote: > Hi, > > I'm working on http://learn.perl.org/ and I'd like to have a few rotating > example of what can be done with Perl on the home page. > > The first two I've thought of are below, does anyone have others? > > They don't have to

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Gabor Szabo
I like this very much: use Spreadsheet::Read; my $ref = ReadData ("test.xls"); say $ref->[1]{A3}; http://search.cpan.org/dist/Spreadsheet-Read/Read.pm Gabor

Re: Cool/useful short examples of Perl?

2011-05-30 Thread David Precious
On Monday 30 May 2011 11:40:57 Leo Lapworth wrote: > Hi, > > I'm working on http://learn.perl.org/ and I'd like to have a few rotating > example of what can be done with Perl on the home page. > > The first two I've thought of are below, does anyone have others? > > They don't have to use CPAN m

Re: Cool/useful short examples of Perl?

2011-05-30 Thread Leo Lapworth
Hi Braudel, On 30 May 2011 12:14, B Maqueira wrote: > I have an example on my blog of a script to build sitemaps using TT & > Mechanize (http://codelab.ferrarihaines.com/archives/135). Feel free to > use it if it suits your purpose... Thanks - it's a too long for what I'm after, I guess putting

Re: Cool/useful short examples of Perl?

2011-05-30 Thread B Maqueira
Hi Leo, I have an example on my blog of a script to build sitemaps using TT & Mechanize (http://codelab.ferrarihaines.com/archives/135). Feel free to use it if it suits your purpose... Cheers... Braudel > Hi, > > I'm working on http://learn.perl.org/ and I'd like to have a few rotating > exampl

Cool/useful short examples of Perl?

2011-05-30 Thread Leo Lapworth
Hi, I'm working on http://learn.perl.org/ and I'd like to have a few rotating example of what can be done with Perl on the home page. The first two I've thought of are below, does anyone have others? They don't have to use CPAN modules, one liners are fine as long as it is simple to see what the

Re: [OffTopic] Anyone sponsoring VISA in UK

2011-05-30 Thread Dave Hodgkinson
I think if you're good enough and the employer has the right shaped hole, it'll just be a process to go through. As long as you your application doesn't look weird, in my experience, border control are reasonably efficient. Stick out and all bets are off. On 30 May 2011, at 06:02, AJ wrote: > h