docs: add developer-workflow.org and language examples

Complete workflow guide for Perl, Python, Go, Ansible, Terraform, Podman.
Includes working example files in examples/ directory.
This commit is contained in:
2026-02-24 16:59:09 +01:00
parent a4df1c1634
commit 9c568a4a0a
8 changed files with 743 additions and 0 deletions

65
examples/perl/example.pl Normal file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env perl
# example.pl — Demonstrates core Perl features for Doom Emacs workflow.
# Navigate: C-M-a/e (sub boundaries), SPC s i (imenu), gd (definition)
# Format: SPC m f (perltidy), Run: SPC m r, Debug: SPC m d
use strict;
use warnings;
use Carp qw(croak);
# --- Subroutine with documentation ---
=head2 parse_config($filename)
Reads a simple key=value config file. Returns a hashref.
=cut
sub parse_config {
my ($filename) = @_;
croak "Filename required" unless defined $filename;
my %config;
open my $fh, '<', $filename
or die "Cannot open '$filename': $!\n";
while (my $line = <$fh>) {
chomp $line;
next if $line =~ /^\s*(?:#|$)/; # skip comments and blanks
if ($line =~ /^(\w+)\s*=\s*(.*)$/) {
$config{$1} = $2;
}
}
close $fh;
return \%config;
}
# --- Array, hash, references ---
my @languages = qw(Perl Python Go);
my %scores = (Perl => 95, Python => 90, Go => 88);
my $lang_ref = \@languages;
my $score_ref = \%scores;
printf "Languages: %s\n", join(', ', @{$lang_ref});
printf "Perl score: %d\n", $score_ref->{Perl};
# --- Regex demo ---
my $text = 'Error: connection refused at 2024-01-15 10:30:00';
if ($text =~ /^(Error|Warning):\s+(.+?)\s+at\s+(\d{4}-\d{2}-\d{2})/) {
printf "Level: %s, Message: %s, Date: %s\n", $1, $2, $3;
}
# --- Error handling with eval/die ---
eval {
my $cfg = parse_config('/tmp/nonexistent.cfg');
print "Loaded config\n";
};
if ($@) {
warn "Caught error: $@";
}
print "Done.\n";