{"id":20559878,"url":"https://github.com/cxw42/list-autonumbered","last_synced_at":"2025-03-06T07:42:00.517Z","repository":{"id":56839539,"uuid":"179072735","full_name":"cxw42/List-AutoNumbered","owner":"cxw42","description":"Automatically add sequential numbers to Perl lists while creating them","archived":false,"fork":false,"pushed_at":"2020-02-25T02:25:48.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T19:02:33.008Z","etag":null,"topics":["line-numbers","list","perl"],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/List::AutoNumbered","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cxw42.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-02T12:26:20.000Z","updated_at":"2022-04-29T13:55:38.000Z","dependencies_parsed_at":"2022-08-29T05:00:54.358Z","dependency_job_id":null,"html_url":"https://github.com/cxw42/List-AutoNumbered","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxw42%2FList-AutoNumbered","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxw42%2FList-AutoNumbered/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxw42%2FList-AutoNumbered/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxw42%2FList-AutoNumbered/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cxw42","download_url":"https://codeload.github.com/cxw42/List-AutoNumbered/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242167984,"owners_count":20082979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["line-numbers","list","perl"],"created_at":"2024-11-16T03:52:31.289Z","updated_at":"2025-03-06T07:42:00.494Z","avatar_url":"https://github.com/cxw42.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    List::AutoNumbered - Add sequential numbers to lists while creating them\n\n    This module adds sequential numbers to lists of lists so you don't have to\n    type all the numbers.  Its original use case was for adding line numbers\n    to lists of testcases.  For example:\n\n        use List::AutoNumbered;                             # line 1\n        my $list = List::AutoNumbered-\u003enew(__LINE__);       # line 2\n        $list-\u003eload(\"a\")-\u003e                                  # line 3\n            (\"b\")                                           # line 4\n            (\"c\")                                           # line 5\n            (\"d\");                                          # line 6\n\n        # Now $list-\u003earr is [ [3,\"a\"], [4,\"b\"], [5,\"c\"], [6,\"d\"] ]\n        # and @$list is ( [3,\"a\"] ... ).\n\n    In general, you can pass any number to the constructor.  For example:\n\n        use List::AutoNumbered;\n        use Test::More tests =\u003e 1;\n\n        my $list = List::AutoNumbered-\u003enew;     # First entry will be number 1\n        $list-\u003eload(\"a\")-\u003e      # Yes, trailing arrow\n            (\"b\")               # Magic!  Don\"t need any more arrows!\n            (\"c\")\n            (\"d\");\n\n        is_deeply($list-\u003earr, [\n            [1, \"a\"], [2, \"b\"], [3, \"c\"], [4, \"d\"]\n        ]);     # Yes, it is!\n\nMETHODS\n  new\n    Constructor.  Basic usage options:\n\n        $list = List::AutoNumbered-\u003enew();      # first list item is number 1\n        $list = List::AutoNumbered-\u003enew($num);  # first list item is $num+1\n        $list = List::AutoNumbered-\u003enew(-at =\u003e $num);   # ditto\n\n    Each successive element will have the next number, unless you say\n    otherwise (e.g., using LSKIP()).  Specifically, the first item in the list\n    will be numbered one higher than the number passed to the\n    \"List::AutoNumbered\" constructor.\n\n    Constructor parameters are processed using Getargs::Mixed, so positional\n    and named parameters are both OK.\n\n   The \"how\" function\n    You can give the constructor a \"how\" function that will make the list\n    entry for a single load() or add() call:\n\n        $list = List::AutoNumbered-\u003enew(-how =\u003e sub { @_ });\n            # Jam everything together to make a flat array\n        $list = List::AutoNumbered-\u003enew(41, sub { @_ });\n            # Positional is OK, too.\n\n    The \"how\" function is called as \"how($num, @data)\".  $num is the line\n    number for load() calls, or \"undef\" for add() calls.  @data is whatever\n    data you passed to \"load()\" or \"add()\".  For example, the default \"how\"\n    function is:\n\n        sub how {\n            shift unless defined $_[0];     # add passes undef as the line number.\n            [@_]                            # Wrap everything in an arrayref.\n        }\n\n    See \"t/05-custom-list-entry.t\" for examples of custom \"how\" functions.\n\n  size\n    Returns the size of the array.  Like \"scalar @arr\".\n\n  last\n    Returns the index of the last element in the array.  Like $#array.\n\n  arr\n    Returns a reference to the array being built.  Please do not modify this\n    array directly until you are done loading it.  List::AutoNumbered may not\n    work if you do.\n\n    This can also be called by using the List::AutoNumbered object as an\n    array:\n\n        my $list = List::AutoNumbered-\u003enew...;\n        foreach my $item (@$list) { ... }    # Instead of my $item (@{$list-\u003earr})\n\n  last_number\n    Returns the current number stored by the instance.  This is the number of\n    the most recently preceding new() or load() call.  This is not the number\n    that will be given to the next record, since that depends on whether or\n    not the next record has a skip (LSKIP()).\n\n  load\n    Push a new record with the next number on the front.  Usage:\n\n        $instance-\u003eload(whatever args you want to push);\n\n    Or, if the current record isn't associated with the number immediately\n    after the previous record,\n\n        $instance-\u003eload(LSKIP $n, args);\n\n    where $n is the number of lines between this \"load()\" call and the last\n    one.\n\n    Returns a coderef that you can call to chain loads.  For example, this\n    works:\n\n        $instance-\u003eload(...)-\u003e(...)(...)(...) ... ;\n        # You need an arrow ^^ here, but don't need any after that.\n\n  add\n    Add to the array being built, without inserting the number on the front. \n    Does increment the number and respect skips, for consistency.\n\n    Returns the instance.\n\nFUNCTIONS\n  LSKIP\n    A convenience function to create a skipper.  Prototyped as \"($)\" so you\n    can use it conveniently with load():\n\n        $instance-\u003eload(LSKIP 1, whatever args...);\n\n    If you are using line numbers, the parameter to \"LSKIP\" should be the\n    number of lines above the current line and below the last new() or load()\n    call.  For example:\n\n        my $instance = List::AutoNumbered-\u003enew(__LINE__);\n        # A line\n        # Another one\n        $instance-\u003eload(LSKIP 2,    # two comment lines between new() and here\n                        'some data');\n\nINTERNAL PACKAGES\n  List::AutoNumbered::Skipper\n    This package represents a skip and is created by LSKIP().  No\n    user-serviceable parts inside.\n\n   new\n    Creates a new skipper.  Parameters are for internal use only and are not\n    part of the public API.\n\nGLOBALS\n  $TRACE\n    (Default falsy) If truthy, print trace output.  Must be accessed directly\n    unless requested on the \"use\" line.  Either of the following works:\n\n        use List::AutoNumbered; $List::AutoNumbered::TRACE=1;\n        use List::AutoNumbered q(*TRACE); $TRACE=1;\n\nAUTHOR\n    Christopher White, \"\u003ccxwembedded at gmail.com\u003e\"\n\nBUGS\n    Please report any bugs or feature requests through the web interface at\n    \u003chttps://github.com/cxw42/List-AutoNumbered/issues\u003e.  I will be notified,\n    and then you'll automatically be notified of progress on your bug as I\n    make changes.\n\nSUPPORT\n    You can find documentation for this module with the perldoc command.\n\n        perldoc List::AutoNumbered\n\n    You can also look for information at:\n\n    *   MetaCPAN\n\n        \u003chttps://metacpan.org/pod/List::AutoNumbered\u003e\n\n    *   Appveyor (CI builds)\n\n        \u003chttps://ci.appveyor.com/project/cxw42/list-autonumbered\u003e\n\nACKNOWLEDGEMENTS\n    Thanks to zdim \u003chttps://stackoverflow.com/users/4653379/zdim\u003e for\n    discussion and ideas in the Stack Overflow question\n    \u003chttps://stackoverflow.com/q/50510809/2877364\u003e that was the starting point\n    for this module.\n\n    Thanks to Dan Stewart for code contributions.\n\nLICENSE AND COPYRIGHT\n    Copyright 2019--2020 Christopher White.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the terms of either: the GNU General Public License as published by\n    the Free Software Foundation; or the Artistic License.\n\n    See \u003chttp://dev.perl.org/licenses/\u003e for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxw42%2Flist-autonumbered","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxw42%2Flist-autonumbered","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxw42%2Flist-autonumbered/lists"}