Commit 0281733

xxwhirlpool  ·  2026-06-30 18:37:57 -0400 EDT
parent 1b58187
move urlref to new repo
2 files changed,  +2, -79
+2, -16
......@@ -1,17 +1,3 @@
1-# `urlref`
1+# [moved to another repo](https://bytes.4-walls.net/kat/urlref)
22
3-inspired by [urlref](https://benjaminhollon.com/musings/urlref/) by benjamin hollon, but rewritten as a simple perl script.
4-
5-the script takes a URL and saves it in a file with a generated 5-character alphanumeric code (all uppercase, for less confusion when writing it down). when you want to search for a URL by its code, you use the `--get-code` argument.
6-
7-## usage
8-
9-run `urlref.pl` without any arguments to bookmark a URL. the script accepts this through `STDIN`, and will output the code attached to the URL. both the code and the URL are saved on the same line (separated by a space) in `links.txt` in the same directory as the script.
10-
11-to find a URL with a code, use the `--get-code` argument. for example:
12-
13-```pl
14-./urlref --get-code AKB48
15-```
16-
17-this will return the matching code and URL.
3+sowwy i felt it made more sense in its own repo
+0, -63
......@@ -1,63 +0,0 @@
1-#!/usr/bin/env perl
2-
3-use 5.38.2;
4-use strict;
5-use warnings;
6-
7-use Getopt::Long qw(GetOptions);
8-
9-sub usage {
10- print("Usage: urlref.pl [--get-code|--help]\n
11- run without args to add URL\n");
12- exit 0;
13-}
14-
15-my $getcode;
16-
17-GetOptions(
18- "get-code=s" => \$getcode,
19- "help" => \&usage,
20-) or die "\nif you want to get a URL, supply a code: --get-code [CODE]\n";
21-
22-sub encode {
23- my @chars = ("A".."Z","0".."9","_");
24-
25- my $string;
26- $string .= $chars[int(rand(@chars))] for 1..5;
27-
28- return $string;
29-}
30-
31-sub addurl {
32- my $url = <STDIN>;
33- chomp $url;
34- my $code = encode($url);
35-
36- if (!length $url == 0) {
37- print("code is: $code\n");
38-
39- my $filename = "links.txt";
40-
41- open(my $fh, ">>", "$filename") or die "could not open $filename: $!";
42- print $fh "$code $url\n";
43- close $fh;
44-
45- print("saved URL to file: $filename\n");
46- } else {
47- die("no URL given");
48- }
49-}
50-
51-if ($getcode) {
52- my $filename = "links.txt";
53-
54- open(my $fh, "<", "$filename") or die "could not open $filename: $!";
55- while(my $line = <$fh>) {
56- if($line =~ /^$getcode\s/) {
57- print("found: $line");
58- }
59- }
60- close $fh;
61-} else {
62- addurl
63-}