Skip to content

Couple of CPAN pressies

December 26, 2009

Just uploaded a couple of new modules to CPAN:

The first one you is just a small xmas cracker that you will already know about from my “bare URL” post from last week. Just pull, enjoy for a little while and then chuck away like most xmas cracker toys :)

The second one is a tad similar (ie. Devel::Declare) but with a much more sympathetic syntax by allowing you to create new Quote-Like Operators in Perl with Perl.

For a good end product exemplar have a look at PerlX::QuoteOperator::URL included with the distribution:

use PerlX::QuoteOperator::URL 'qh';

my $content = qh{ http://transfixedbutnotdead.com/ };

There is no scary parsing going on with this example. PerlX::QuoteOperator / Devel::Declare simply hits the ‘qh’ keyword and converts it to:

qh qq{ http://transfixedbutnotdead.com/ }

And ‘qh’ is a subroutine with a ($) prototype. So nothing too sinister (unless you really do abhor subroutine prototypes!), just a simple macro which gives the appearance that we have new quote-like operators.

Certainly an interesting concept to be able to produce new quote-like operators in Perl. So hopefully PerlX::QuoteOperator might find its way under a few xmas trees :)

Merry Xmas & happy St. Stephen’s day to everyone.

/I3az/

PS. I chose the PerlX::* because gugod as already provided some wonderful Devel::Declare Perl extending modules under this namespace. I feel its in the same vein so hopefully a good place for it to live.

About these ads
2 Comments leave one →
  1. January 7, 2010 2:03 pm

    Hey there, cool modules! As for PerlX::QuoteOperator, it looks a lot like Sub::QuoteLike, but using Devel::Declare instead of Filter::Simple (which is a good thing :-)

    Cheers!

    • January 7, 2010 4:16 pm

      Many thanks garu.

      I hadn’t noticed Sub::Quotelike previously but yes I agree that PerlX::QuoteOperator with Devel::Declare is the more modern solution.

      I am/was planning to do a follow up post about Perl having definable quote like operators natively. This is my “new” syntax proposal:

      sub quote (q) { ... }
      
      sub quotequote (qq) { ... interpolated quote ... }
      
      sub words (qw) { ... }
      

      So its good to see its not a million miles different to syntax used in Sub::QuoteLike. So its probably not such a madcap idea after all :)

      /I3az/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: