Underscore - Perl port of Underscore.js
use Underscore; _([3, 2, 1])->sort;
Underscore Perl is a clone of a popular JavaScript library http://github.com/documentcloud/underscore|Underscore.js. Why? Because Perl is awesome. And because we can!
/\ \ __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\ \/\ \ /' _ `\ /'_` \ /'__`\/\`'__\/',__\ /'___\ / __`\/\`'__\/'__`\ \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\ \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/ ___ __ /\_ \ /\_\ ___ _____ __ _ __\//\ \ \/\ \ /' _ `\ /\ '__`\ /'__`\/\`'__\\ \ \ \ \ \/\ \/\ \ \ \ \ \ \/\ __/\ \ \/ \_\ \_ \ \_\ \_\ \_\ \ \ ,__/\ \____\\ \_\ /\____\ \/_/\/_/\/_/ \ \ \/ \/____/ \/_/ \/____/ \ \_\ \/_/
This document describes the differences. For the full introduction see original page of http://documentcloud.github.com/underscore/|Underscore.js.
The test suite is compatible with the original one, except for those functions that were not ported.
All the methods have CamelCase aliases. Use whatever you like. I personally prefer underscores.
Objects are simply hashes, not Perl objects. Maybe objects will be added later.
Of course not everything was ported. Some things don't make any sense for Perl, other are impossible to implement without depending on event loops and async programming.
Most of the functions are just wrappers around built-in functions. Others use List::Util and List::MoreUtils modules.
Numeric/String detection is done the same way JSON::PP does it: by using B hacks.
Boolean values are implemented as overloaded methods, that return numbers or strings depending on the context.
_->true; _->false;
You can use Perl version in either an object-oriented or a functional style, depending on your preference. The following two lines of code are identical ways to double a list of numbers.
_->map([1, 2, 3], sub { my ($n) = @_; $n * 2; }); _([1, 2, 3])->map(sub { my ($n) = @_; $n * 2; });
http://github.com/vti/underscore-perl
Undescore.js authors and contributors
Viacheslav Tykhanovskyi, vti@cpan.org Rich Douglas Evans, rich.douglas.evans@gmail.com
vti@cpan.org
rich.douglas.evans@gmail.com
Copyright (C) 2011-2012, Viacheslav Tykhanovskyi Copyright (C) 2013 Rich Douglas Evans
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
To install Underscore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Underscore
CPAN shell
perl -MCPAN -e shell install Underscore
For more information on module installation, please visit the detailed CPAN module installation guide.