aboutsummaryrefslogtreecommitdiff
path: root/challenge-028
diff options
context:
space:
mode:
authorRuben Westerberg <drclaw@mac.com>2019-10-06 11:21:41 +1000
committerRuben Westerberg <drclaw@mac.com>2019-10-06 11:21:41 +1000
commit87fb34a6e91686a017033aae0276891e846fb14d (patch)
tree29021856fe340ec213145593ad6f2c708a86ff0d /challenge-028
parenta9e9556a2537400c7f7f48d27241f755865dc3fa (diff)
downloadperlweeklychallenge-club-87fb34a6e91686a017033aae0276891e846fb14d.tar.gz
perlweeklychallenge-club-87fb34a6e91686a017033aae0276891e846fb14d.tar.bz2
perlweeklychallenge-club-87fb34a6e91686a017033aae0276891e846fb14d.zip
Added ch-1.pl
Diffstat (limited to 'challenge-028')
-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