summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-06-24 16:14:25 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-06-24 16:14:25 +0200
commit8d1e7ef8e8e05e052772eccf3beabfc461d85ec3 (patch)
tree18e84b7390da6413b27a227f6b3d9c8ab988a78f /bin
parent86c3e3526179429c5fa12ecb9aa2eb7d2c0a7a9b (diff)
db-ris: Add --via (regex filter)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/db-ris7
1 files changed, 7 insertions, 0 deletions
diff --git a/bin/db-ris b/bin/db-ris
index 80d3d0f..8514831 100755
--- a/bin/db-ris
+++ b/bin/db-ris
@@ -6,16 +6,19 @@ use 5.010;
our $VERSION = '0.0';
use Getopt::Long;
+use List::Util qw(first);
use Travel::Status::DE::DeutscheBahn;
my ( $date, $time );
my $types = q{};
my %train_type;
+my $filter_via;
binmode( STDOUT, ':encoding(utf-8)' );
GetOptions(
'd|date=s' => \$date,
+ 'v|via=s' => \$filter_via,
'm|mot=s' => \$types,
't|time=s' => \$time,
);
@@ -42,6 +45,10 @@ for my $d ( $status->departures() ) {
@via = $d->route;
+ if ( $filter_via and not( first { $_ =~ m{$filter_via}io } @via ) ) {
+ next;
+ }
+
for my $stop (@via) {
if ( $stop =~ m{ ?Hbf} ) {
push( @via_main, $stop );