URL Generator Section

#!/usr/bin/perl
use strict;
use warnings;

# Read entire input from STDIN
my $input = do { local $/; <STDIN> };

# Hash to store unique handles
my %handles;

# Extract @handles (letters, digits, underscores)
while ($input =~ /@([A-Za-z0-9_]{1,15})/g) {
    $handles{$1} = 1;
}

# --- URL Generator Section ---

# Convert text into SEO-friendly slug
sub make_slug {
    my ($text) = @_;

    # Lowercase
    $text = lc($text);

    # Remove non-word characters except spaces
    $text =~ s/[^a-z0-9\s]+//g;

    # Collapse whitespace
    $text =~ s/\s+/ /g;

    # Replace spaces with hyphens
    $text =~ s/ /-/g;

    return $text;
}

# Generate URL-safe slug from input
my $slug = make_slug($input);

# Build full wiki URL
my $base = "https://www.lowmaintenancesweetheart.online/index.php?title=";
my $url  = $base . $slug;

# --- Output Section ---

print "Collected handles:\n";
for my $h (sort keys %handles) {
    print "\@$h\n";
}

print "\nGenerated SEO URL:\n$url\n";

# Sanitise text (basic)
$input =~ s/[^\w\s\@\.\-]//g;

print "\nSanitised text:\n$input\n";

Leave a Reply

Your email address will not be published. Required fields are marked *