Support tags for individual tips
[grml-tips.git] / grml-tips-tags
1 #!/usr/bin/perl
2 # Filename:      grml-tips-tags
3 # Purpose:       Extract available patterns from grml-tips file
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>, (c) Alexander Wirt <formorer@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 ################################################################################
8
9 use strict;
10
11 my $grml_tips = '/usr/share/grml-tips/grml_tips';
12 open (my $fh, '<', $grml_tips) or die "Could not open $grml_tips: $!";
13
14 my @tags;
15
16 while (my $line = <$fh>) {
17     next unless $line =~ /^Tags: (.*)$/;
18     push @tags, split(/[, ]+/, $1);
19 }
20
21 #make tags unique
22 my %seen = ();
23 @tags = grep { ! $seen{$_} ++ } @tags;
24
25 print join("\n", @tags) . "\n";