{ "info": { "author": "Richard Terry", "author_email": "code@radiac.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Perl", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "========================\nPerl as a Python package\n========================\n\n.. image:: https://travis-ci.org/radiac/python-perl.svg?branch=master\n :target: https://travis-ci.org/radiac/python-perl\n\n.. image:: https://coveralls.io/repos/radiac/python-perl/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/radiac/python-perl?branch=master\n\n\nHaven't you always dreamed of having the power of Perl at your fingertips when writing\nPython?\n\nWell, this package is proof that dreams can come true::\n\n >>> import perl\n >>> value = \"Hello there\"\n >>> if value =~ /^hello (.+?)$/i:\n ... print(\"Found greeting:\", $1)\n ...\n Found greeting: there\n >>> value =~ s/there/world/\n >>> print(value)\n Hello world\n\n\nNote: This is very silly and probably shouldn't go anywhere near production code.\n\n* Project site: http://radiac.net/projects/python-perl/\n* Source code: https://github.com/radiac/python-perl\n\n\nInstallation\n============\n\nThis requires Python 3.7 or later.\n\n\nUsage\n=====\n\nThe module needs to be loaded before Python tries to read code which uses these\nenhancements. There are therefore four different ways to use this module:\n\n1. Pass it to Python on the command line::\n\n python3.7 -m perl myscript.py\n\n2. Set it on your script's shebang::\n\n #!/usr/bin/python3.7 -mperl\n\n3. Import it before importing any of your code which uses its syntax - usually in\n your ``__init__.py``::\n\n import perl\n\n .. note::\n\n You only need to import it once in your project.\n\n However, because Python needs to read the whole file before it can run the\n import, you cannot use ``perl``'s functionality in the same file where you\n ``import perl``.\n\n4. Use it on the Python interactive shell (REPL)::\n\n $ python3.7\n >>> import perl\n\n or::\n\n $ python3.7 -m perl\n\n\nFeatures\n========\n\nRegular expression matching\n---------------------------\n\nSyntax::\n\n val =~ /pattern/flags\n # or\n val =~ m/pattern/flags\n\nwhere ``pattern`` uses `Python's regex syntax`_, and ``flags`` is a subset of the\ncharacters ``AILMSXG``, which map Python's single character flags, plus ``g`` which\nmimics the global flag from Perl.\n\nWhen run without the global flag, the ``re.Match`` object is returned; any matched\ngroups will be available as numbered dollar variables, eg ``$1``, and named groups will\nbe available on ``$name``.\n\nWhen run with the global flag, the list of ``re.Match`` objects will be returned. No\ndollar variables will be set.\n\n.. _Python's regex syntax: https://docs.python.org/3/library/re.html#regular-expression-syntax\n\nExamples::\n\n # Case insensitive match\n value =~ /^foo (.+?) bar$/i\n print(f\"Matched {$1}\")\n\n # Use in a condition\n if value =~ /^foo (.+?) bar$/i:\n return $1\n\n # Use as a global\n matches = value =~ /foo (.+?) bar/gi;\n\n\nRegular expression replacement\n------------------------------\n\nSyntax:\n\n val =~ s/pattern/replacement/flags\n\nwhere ``pattern`` uses `Python's regex syntax`_, and ``flags`` is a subset of the\ncharacters ``AILMSXG``, which map Python's single character flags, plus ``g`` which\nmimics the global flag from Perl to replace all occurrences of the match.\n\nExamples::\n\n # Case insensitive global replacement\n value =~ s/foo/bar/gi\n\n\nDollar variables\n----------------\n\nSyntax::\n\n $name\n $number\n\nDollar variables act like regular variables - they can be set and used as normal. They\nare primarily intended for use with regular expressions - each regex will remove all\nprevious dollar variables, to avoid confusion as to whether they matched or not.\n\n\nContributing\n============\n\nDuring development, install in a virtual environment::\n\n mkdir python-perl\n cd python-perl\n git clone repo\n virtualenv --python=python3.7 venv\n . venv/bin/activate\n cd repo\n pip install -r requirements.txt\n\n\nTo run tests::\n\n cd path/to/repo\n . ../venv/bin/activate\n pytest\n\n\nTo run the example, use one of the following::\n\n $ ./example.py\n $ python3.7 -m perl example.py\n $ python3.7 example_importer.py", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://radiac.net/projects/python-perl/", "keywords": "socket telnet", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "perl", "package_url": "https://pypi.org/project/perl/", "platform": "", "project_url": "https://pypi.org/project/perl/", "project_urls": { "Homepage": "http://radiac.net/projects/python-perl/" }, "release_url": "https://pypi.org/project/perl/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Perl as a Python package", "version": "1.0.0" }, "last_serial": 5806545, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "8dba21c89ea720eb7fe0c4228790aab4", "sha256": "3c3611359baf102e798c10651c551dfe643a9123f225b3924f23f2a269b7acb3" }, "downloads": -1, "filename": "perl-0.1.tar.gz", "has_sig": false, "md5_digest": "8dba21c89ea720eb7fe0c4228790aab4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 718, "upload_time": "2016-09-22T04:34:20", "url": "https://files.pythonhosted.org/packages/4c/06/39f3fca8c913d4b21079f9cbfe32b9b501fab9f03732d4b77cf8f7c01c2e/perl-0.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "895c883ca773b6da71ca1b50f5d5abf1", "sha256": "d17aa3de50e535dd95842246f4b0d0d7713d787171c8464aa63b5c82df3a601e" }, "downloads": -1, "filename": "perl-1.0.0.tar.gz", "has_sig": false, "md5_digest": "895c883ca773b6da71ca1b50f5d5abf1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11194, "upload_time": "2019-09-10T02:32:35", "url": "https://files.pythonhosted.org/packages/cb/2f/d2724ee752dc50c6eb4273ab5c486ce43737866072f15bd089e449003fd2/perl-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "895c883ca773b6da71ca1b50f5d5abf1", "sha256": "d17aa3de50e535dd95842246f4b0d0d7713d787171c8464aa63b5c82df3a601e" }, "downloads": -1, "filename": "perl-1.0.0.tar.gz", "has_sig": false, "md5_digest": "895c883ca773b6da71ca1b50f5d5abf1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11194, "upload_time": "2019-09-10T02:32:35", "url": "https://files.pythonhosted.org/packages/cb/2f/d2724ee752dc50c6eb4273ab5c486ce43737866072f15bd089e449003fd2/perl-1.0.0.tar.gz" } ] }