• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Turning AI into a Developer Superpower: The PERL5LIB Auto-Setter

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Like most developers, I have a mental folder labelled “useful little tools I’ll probably never build.” Small utilities, quality-of-life scripts, automations — they’d save time, but not enough to justify the overhead of building them. So they stay stuck in limbo.

That changed when I started using AI as a regular part of my development workflow.

Now, when I hit one of those recurring minor annoyances — something just frictiony enough to slow me down — I open a ChatGPT tab. Twenty minutes later, I usually have a working solution. Not always perfect, but almost always 90% of the way there. And once that initial burst of momentum is going, finishing it off is easy.

It’s not quite mind-reading. But it is like having a superpowered pair programmer on tap.

The Problem


Obviously, I do a lot of Perl development. When working on a Perl project, it’s common to have one or more lib/ directories in the repo that contain the project’s modules. To run test scripts or local tools, I often need to set the PERL5LIB environment variable so that Perl can find those modules.

But I’ve got a lot of Perl projects — often nested in folders like ~/git, and sometimes with extra lib/ directories for testing or shared code. And I switch between them frequently. Typing:


export PERL5LIB=lib

…over and over gets boring fast. And worse, if you forget to do it, your test script breaks with a misleading “Can’t locate Foo/Bar.pm” error.

What I wanted was this:


  • Every time I cd into a directory, if there are any valid lib/ subdirectories beneath it, set PERL5LIB automatically.


  • Only include lib/ dirs that actually contain .pm files.


  • Skip junk like .vscode, blib, and old release folders like MyModule-1.23/.


  • Don’t scan the entire world if I cd ~/git, which contains hundreds of repos.


  • Show me what it’s doing, and let me test it in dry-run mode.
The Solution


With ChatGPT, I built a drop-in Bash function in about half an hour that does exactly that. It’s now saved as

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, and it:


  • Wraps cd() to trigger a scan after every directory change


  • Finds all qualifying lib/ directories beneath the current directory


  • Filters them using simple rules:


  • Excludes specific top-level directories (like ~/git) by default


  • Lets you configure everything via environment variables


  • Offers verbose, dry-run, and force modes


  • Can append to or overwrite your existing PERL5LIB

You drop it in your ~/.bashrc (or wherever you like), and your shell just becomes a little bit smarter.

Usage Example


source ~/bin/perl5lib_auto.sh

cd ~/code/MyModule
# => PERL5LIB set to: /home/user/code/MyModule/lib

PERL5LIB_VERBOSE=1 cd ~/code/AnotherApp
# => [PERL5LIB] Found 2 eligible lib dir(s):
# => /home/user/code/AnotherApp/lib
# => /home/user/code/AnotherApp/t/lib
# => PERL5LIB set to: /home/user/code/AnotherApp/lib:/home/user/code/AnotherApp/t/lib

You can also set environment variables to customise behaviour:


export PERL5LIB_EXCLUDE_DIRS="$HOME/git:$HOME/legacy"
export PERL5LIB_EXCLUDE_PATTERNS=".vscode:blib"
export PERL5LIB_LIB_CAP=5
export PERL5LIB_APPEND=1

Or simulate what it would do:


PERL5LIB_DRYRUN=1 cd ~/code/BigProject
Try It Yourself


The full script is available on GitHub:


I’d love to hear how you use it — or how you’d improve it. Feel free to:


  • ⭐ Star the repo


  • ? Open issues for suggestions or bugs


  • ? Send pull requests with fixes, improvements, or completely new ideas

It’s a small tool, but it’s already saved me a surprising amount of friction. If you’re a Perl hacker who jumps between projects regularly, give it a try — and maybe give AI co-coding a try too while you’re at it.

What useful little utilities have you written with help from an AI pair-programmer?

The post

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

first appeared on

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу