shlomi-fish-homepage / t2 / humour / fortunes / generate-web-feeds.pl

use strict;
use warnings;

use Cwd;
use File::Spec;
use String::ShellQuote;
use Getopt::Long;

my $master_url = "http://www.shlomifish.org/humour/fortunes/";

my $atom_arg;
my $rss_arg;
my $dir_arg;

GetOptions(
    "atom=s" => \$atom_arg,
    "dir=s" => \$dir_arg,
    "rss=s" => \$rss_arg,
);

my $abs_dir = File::Spec->rel2abs($dir_arg);
my $abs_atom = File::Spec->rel2abs($atom_arg);
my $abs_rss = File::Spec->rel2abs($rss_arg);

open my $arcs_list_fh, "<", "$dir_arg/fortunes-list.mak";
my @lines = <$arcs_list_fh>;
close($arcs_list_fh);

shift(@lines);

my @fortunes = (map { /([\w\-_]+)/ ; $1 } @lines);

my @cmd_line =
(
    $^X,
    "-MXML::Grammar::Fortune::Synd::App",
    "-e",
    "run(); exit(0);",
    "--",
    "--dir" => $abs_dir,
    (map { ("--xml-file" , "$_.xml") } (@fortunes)),
    "--yaml-data" => "$abs_dir/fortunes-shlomif-ids-data.yaml",
    "--atom-output" => $abs_atom,
    "--rss-output" => $abs_rss,
    "--master-url" => $master_url,
    "--title" => "Shlomi Fish's Fortune Feeds",
    "--tagline" => "Shlomi Fish's Fortune Feeds",
    "--author" => "shlomif\@iglu.org.il (Shlomi Fish)",
);

print join(" ", map { m{ } ? qq{"$_"} : $_ } @cmd_line), "\n";
exit(system(@cmd_line));
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.