An AI-powered tool for converting Perl code to Python.
# Install the package
pip install -e .
# Convert a Perl file to Python
perl2python path/to/your/script.pl
# Convert a directory of Perl files
perl2python path/to/perl/dir -o path/to/python/dir -r
# Get help
perl2python --help
An AI-powered Perl to Python conversion agent has been successfully implemented, including a well-defined directory structure, essential modules, and comprehensive documentation. The implementation is complete and ready for use, with the repository said to be structured appropriately for future enhancements. No errors or significant issues were noted during the process.
src/perl2python/
: Main package source code__init__.py
: Package initializationconverter.py
: Core conversion logiccli.py
: Command-line interface__main__.py
: Entry point for running as a module
tests/
: Test filessample_perl/
: Sample Perl files for testingtest_converter.py
: Unit tests for the converter
docs/
: DocumentationREADME.md
: Detailed documentation
examples/
: Example scriptsprogrammatic_usage.py
: Examples of using the converter in Python code
- Convert individual Perl files or entire directories to Python
- Preserve code structure and comments
- Map Perl modules to their Python equivalents
- Convert Perl's special variables to Python equivalents
- Handle Perl-specific syntax like variable prefixes (
$
,@
,%
) - Support for Perl's loop constructs (for, foreach, while, until)
- Support for Perl's regex operations (match, substitution, translation)
- Support for Perl's hash and array operations
- Automatic post-processing to fix common conversion issues
- Customizable conversion through configuration files
- Command-line interface for easy integration into workflows
For detailed documentation, see the docs/README.md file.
Check out the examples directory for examples of how to use the converter programmatically.
Run the tests with:
python -m unittest discover tests
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.