PrePAN

Sign in to PrePAN

PrePAN provides a place
to discuss your modules.

CLOSE

Requests for Reviews Feed

Perl::Critic::Policy::ProhibitSmartmatch Perl::Critic policies which help to avoid both explicit and implicit smartmatching

holcapek@github 1 comment

Device::Network::ConfigParser Network Device Configuration Parser

This module is a harness to take in network device (think switches, routers, etc) configuration, parse them, and output them in specified formats.

As an example, it takes an Cisco ASA config, parse the objects, object-groups, NATs, etc.

The harness is used by the command line utility 'ncp'.

The specific parsers and output drivers are dynamically loaded based on the command line arguments.

gregfoletta@github 1 comment

IO::ReadHandle::Chain Chain read handles

This module provides a mechanism to chain any number of data sources together for reading through a single file handle. This is convenient if you have multiple sources of which some are very large and you need to pretend that they are all inside a single source.

One application is to pretend to wrap a huge file of XML elements in a root element so that it becomes acceptable to XML parsers such as XML::Twig, without actually having to create a modified copy of the huge file:

use IO::ReadHandle::Chain;
use XML::Twig;

$prefix = '<wrapper>';
$suffix = '</wrapper>';
$cfh = IO::ReadHandle::Chain->new(\$prefix, 'huge.xml', \$suffix);
$twig = XML::Twig->new( twig_handlers => { ... } );
$twig->parse($cfh);

NOTE: Read < for &lt; and > for &gt; above. I cannot figure out the Markdown to make them show up correctly.

LouisStrous@github 1 comment

WebApp-Snippy minimalist note-taking web application

A demonstration Perl Dancer CRUD web application written for my capstone course at Independence University

mjgardner@github 0 comments

Sort::Naturally::ICU Perl extension for human-friendly ("natural") sort order, which using ICU library for locale aware sorting.

DESCRIPTION

See: http://search.cpan.org/~serval/Sort-Naturally-XS-0.7.8/lib/Sort/Naturally/XS.pm#DESCRIPTION

LOCALE AWARE SORTING

The following example demonstrates default way to locale aware sorting:

use POSIX;

my @list = ('a'..'c', 'A'..'C');

setlocale(POSIX::LC_ALL, 'en_US.utf8');
my @result = sort @list;
# @result contains  a, A, b, B, c, C

setlocale(POSIX::LC_ALL, 'en_CA.utf8');
@result = sort @list;
# @result contains  A, a, B, b, C, c

The problem is that not all Unix-like OSs completely support POSIX, in fact only Linux fully POSIX compatible. Therefore you can't use above approach in Mac OS or FreeBSD. This module is designed to solve this issue.

To be able to sort a list with an arbitrary locale at any platform it's necessary to use the sorted function with a locale keyword argument. locale should be LDML locale identifier:

use Sort::Naturally::ICU qw/sorted/;

my $list = ['a'..'c', 'A'..'C'];

my $result_us = sorted($list, locale => 'en-US-u-va-posix');
# $result_us contains A, B, C, a, b, c

my $result_ca = sorted($list, locale => 'en-CA-u-va-posix');
# $result_ca contains a, A, b, B, c, C

the_serval@twitter 0 comments

Plack::App::URLMux PSGI/Plack component for dispatching multiple applications based on URL path and patterns

The module is designed for multiplexing applications by URL path and patterns. This module is based on Plack::App::URLMap, but it optimized to dispatching a lot of URLs without performance regression. Additionally this module provide the ability to assign routing rules using URL patterns with named parameters. The format of parameter consist of ':' followed by parameter name and quantifier which is the same as for regexp expressions.

The idea was in that URL in RFC1738 for HTTP defined as hierarchical resource locator with '/' as delimeter and the package splits url-path on this parts, searches the application by them in mapped search tree and fills the matched named patters. This module defines value of a named parameter as one o more parts of the url-path (hsegment in RFC terms) in array context and returns list of matched parameters in PSGI/Plack environment 'plack.urlmux,params.url' as array of name and value pairs.

The namespace for Plack additional modules can be used for components as Plack::App and for middleware as Plack::Middleware, so I have chosen the Plack::App::URLMux name. I send a email to author of Plack modules about naming the module and did not receive feedback, so I decide to write about the package here.

I don`t like the idea to implement a URL multiplexer as regexp expression URL parser as in (Python dispatcher)[https://docs.djangoproject.com/en/1.11/topics/http/urls/#example] for example, due its performance issues for a lot of URL rules. This module solves the performance problem by simplify the regexp expressions to named patterns and operates more larger constructions - url-path segments.

Any suggestions, comments and criticism are welcome.

AlexBurnes@github 0 comments

Convert::Maker Make a conversion generator for fixed keys

A conversion generator which outputs C code. The C code output converts hash keys to values in the style of Data::Munge's list2re or lex. Construct automata to translate a fixed list of inputs into a certain set of outcomes.

The projected use of this is in creating very fast converters for translating symbol tables into other symbols. For example, to convert "ASCII IPA" into Unicode symbols very rapidly, to convert Chinese characters into Pinyin, etc.

benkasminbullock@github 0 comments

Code::Search Search code for strings

Search source code for strings.

Trigram index of medium number (40,000 or so) source code files.

Already have developed code but it is not in a state fit to release, and it is all in C except for a few scripts.

benkasminbullock@github 4 comments

Hash::Wrap (formerly Return::Object) create lightweight on-the-fly objects from hashes

UPDATE

This module is now known as Hash::Wrap

The text below represents the original module, Return::Object. Please see the github repo for the current documentation.

DESCRIPTION

This module provides routines which encapsulate a hash as an object. The object provides methods for keys in the hash; attempting to access a non-existent key via a method will cause an exception.

The impetus for this was to encapsulate data returned from a subroutine or method (hence the name). Returning a bare hash can lead to bugs if there are typos in hash key names when accessing the hash.

It is not necessary for the hash to be fully populated when the object is created. The underlying hash may be manipulated directly, and changes will be reflected in the object's methods. To prevent this, consider using the lock routines in Hash::Util on the object after creation.

Only hash keys which are legal method names will be accessible via object methods.

Object construction and constructor customization

By default Object::Return exports a return_object constructor which, given a hashref, blesses it directly into the Return::Object::Class class.

The constructor may be customized to change which class the object is instantiated from, and how it is constructed from the data. Return::Object uses Exporter::Tiny to perform the customization. For example,

use Return::Object
  return_object => { -as => 'return_cloned_object',
                     -clone => 1 };

will create a version of return_object which clones the passed hash and is imported as return_cloned_object. To import it under the original name, return_object, leave out the -as option.

The following options are available to customize the constructor.

  • -as => subroutine name

    This is optional, and imports the customized version of return_object with the given name.

  • -class => class name

    The object will be blessed into the specified class. If the class should be created on the fly, specify the -create option. See "Object Classes" for what is expected of the object classes. This defaults to Object::Return::Class.

  • -create => boolean

    If true, and -class is specified, a class with the given name will be created.

  • -copy => boolean

    If true, the object will store the data in a shallow copy of the hash. By default, the object uses the hash directly.

  • -clone => boolean

    If true, the object will store the data in a deep copy of the hash, made with "dclone" in Storeable. By default, the object uses the hash directly.

Object Classes

An object class has the following properties:

  • The class must be a subclass of Return::Object::Base.
  • The class typically does not provide any methods, as they would mask a hash key of the same name.
  • The class need not have a constructor. If it does, it is passed a hashref which it should bless as the actual object. For example:

    package My::Result;
    use parent 'Return::Object::Base';
    
    
    sub new {
      my  ( $class, $hash ) = @_;
      return bless $hash, $class;
    }
    

    This excludes having a hash key named new.

Return::Object::Base provides an empty DESTROY method, a can method, and an AUTOLOAD method. They will mask hash keys with the same names.

BUGS AND LIMITATIONS

You can make new bug reports, and view existing ones, through the web interface at https://rt.cpan.org/Public/Dist/Display.html?Name=Return-Object.

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007

djerius@github 3 comments

Types::PDL PDL types using Type::Tiny

DESCRIPTION

This module provides Type::Tiny compatible types for PDL.

Types

Piddle

Allows an object blessed into the class PDL, e.g.

validate( [pdl], Piddle );

Piddle accepts the following parameters ("Parameters"):

empty
ndims
ndims_min
ndims_max

Parameters

Some types take optional parameters which add additional constraints on the object. For example, to indicate that only empty piddles are accepted:

validate( [pdl], Piddle[ empty => 1 ] );

The available parameters are:

  • empty

    This accepts a boolean value; if true the piddle must be empty (i.e. the isempty method returns true), if false, it must not be empty.

  • null

    This accepts a boolean value; if true the piddle must be a null piddle, if false, it must not be null.

  • ndims

    This specifies a fixed number of dimensions which the piddle must have. Don't mix use this with ndims_min or ndims_max.

  • ndims_min

    The minimum number of dimensions the piddle may have. Don't specify this with ndims.

  • ndims_max

    The maximum number of dimensions the piddle may have. Don't specify this with ndims.

djerius@github 0 comments