Use GitLab Duo and AI to understand and refactor the provided source code from Perl to Python.
We not only refactor Perl to Python but also explore how to make the Perl code more robust. After refactoring the code to Python, we added new functionality to parse Markdown image tags and debug the regular expressions used.
As a bonus, we ask Duo Chat to refactor Perl into Ruby, PHP, Rust, Go, cC C++, Java, C#, VB.NET, Bash, PowerShell and more.
Created with GitLab.com and Claude 3.5 for Duo Chat.
Resources
- Blog post embedding this video and more refactoring best practices [ Ссылка ]
- GitLab project with challenges, resources, tips: [ Ссылка ]
- GitLab Duo: [ Ссылка ]
- GitLab Duo Code Suggestions: [ Ссылка ]
- GitLab Duo Chat: [ Ссылка ]
- Supported IDEs: [ Ссылка ]
- GitLab Duo Use Cases: [ Ссылка ]
Blog tutorials:
- Top tips for efficient AI-powered Code Suggestions with GitLab Duo: [ Ссылка ]
- 10 best practices for using AI-powered GitLab Duo Chat [ Ссылка ]
TOC:
0:00 Introduction and Perl script overview
1:38 Ask Duo Chat to /explain
2:35 Run the Perl script
3:10 Refactor the script with Duo Chat
3:45 Ask Duo Chat what sub is in Perl
4:55 /refactor use telling variable names and full words for the summary text
6:13 /refactor into Python
7:05 Run the generated Python script
8:03 /refactor into Python, use telling variable names, functions, full text summaries
9:48 It works
11:49 Explain the code
12:05 Add functionality with /refactor
13:05 Use Code Suggestions in the function to add image tag parsing
15:35 Test and fix missing image tags in md file
16:04 Ask Duo Chat how to create an image embed for Youtube URL into Markdown
17:25 Fix regex for image tags using /refactor
18:30 Explain the script error in Duo Chat
18:56 Add missing re import to fix the script
19:19 Recap: Learned today
20:42 Bonus: Refactor into more languages - Ruby
21:10 Refactor into PHP
21:49 Refactor into Go
22:30 Refactor into Rust
22:53 Refactor into C
23:33 Refactor into C++
24:10 Refactor into Java
24:42 Refactor into C#
25:04 Refactor into Visual Basic .NET
25:57 Refactor into Bash
26:32 Refactor into PowerShell
27:18 Bonus recap
![](https://s2.save4k.ru/pic/03HGhxXg9lw/maxresdefault.jpg)