#!/usr/bin/perl -w
#
# $Revision: 1.4 $ $Date: 2012-07-26 17:11:49-04 $
# $Source: /home/vogelke/bin/RCS/uri2path,v $
# $Host: sys7.com $
# $UUID: 9f61a958-00a8-3612-8c76-ec738b3000d6 $
#
#< uri2path: accept a URI starting with file://, and print the path.

use Cwd 'realpath';
use strict;

if (@ARGV) {
    foreach (@ARGV) {
        decode($_);
    }
} else {
    while (<>) {
        chomp;
        decode($_);
    }
}

exit(0);

sub decode {
    my $uri = shift;
    $uri =~ s!^file://!!;
    $uri =~ s/%([a-f0-9][a-f0-9])/chr( hex( $1 ) )/gei;
    print "$uri\n";
}
