aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-028/ruben-westerberg/perl5/ch-1.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-028/ruben-westerberg/perl5/ch-1.pl b/challenge-028/ruben-westerberg/perl5/ch-1.pl
new file mode 100755
index 0000000000..b545710959
--- /dev/null
+++ b/challenge-028/ruben-westerberg/perl5/ch-1.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use File::Basename;
+my %ext;
+while (<DATA>) {
+ s/(:?\s+)|(:?,)/ /g;
+ my @f=split(" ");
+ my $type= shift(@f) =~ /^text\// ? "text": "binary";
+ $ext{$_}=$type for @f;
+}
+for (@ARGV) {
+ my ($filename, $dir, $suffix)=fileparse($_, qr/\.[^.]*/);
+ my $type=$ext{substr $suffix, 1};
+ $type="binary" if ! $type;
+ print "$_: The file content is $type\n";
+
+
+}
+
+__DATA__
+text/html html htm shtml
+text/css css
+text/xml xml
+text/mathml mml
+text/plain txt
+text/vnd.sun.j2me.app-descriptor jad
+text/vnd.wap.wml wml
+text/x-component htc