summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Prelude.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-11-27 09:18:21 +0100
committerYorhel <git@yorhel.nl>2019-11-27 14:28:18 +0100
commit4067f0a73a55e898def7320976781a2b8bf6710b (patch)
treea334579a9e0389337238cf13e19851156c2b9fd2 /lib/VNWeb/Prelude.pm
parent9c4835a94263127f780c0b96db89aa25ceefd960 (diff)
ulist: Add column selection + voted, modified, release date & rating columns
It works pretty well, but Lists.pm is getting *really* ugly now. :(
Diffstat (limited to 'lib/VNWeb/Prelude.pm')
-rw-r--r--lib/VNWeb/Prelude.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/VNWeb/Prelude.pm b/lib/VNWeb/Prelude.pm
index 10fc3b8d..bf1db2a0 100644
--- a/lib/VNWeb/Prelude.pm
+++ b/lib/VNWeb/Prelude.pm
@@ -69,6 +69,7 @@ sub import {
no strict 'refs';
*{$c.'::RE'} = *RE;
*{$c.'::json_api'} = \&json_api;
+ *{$c.'::in'} = \&in;
}
@@ -129,4 +130,17 @@ sub json_api {
};
}
+
+# Simple "is this element in the array?" function, using 'eq' to test equality.
+# Supports both an @array and \@array.
+# Usage:
+#
+# my $contains_hi = in 'hi', qw/ a b hi c /; # true
+#
+sub in {
+ my($q, @a) = @_;
+ $_ eq $q && return 1 for map ref $_ eq 'ARRAY' ? @$_ : ($_), @a;
+ 0
+}
+
1;