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