diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-12-02 16:49:56 +0100 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-12-02 16:49:56 +0100 |
| commit | 448a7d3303561035df18267c6ca1e5d9df55c049 (patch) | |
| tree | bb58c5fb15388b779ab01af7bb8c7b445f05a416 | |
| parent | d50462884ae59b78ac9eb2cacfbf6d016687a091 (diff) | |
| download | Skriptsprachen-448a7d3303561035df18267c6ca1e5d9df55c049.tar.gz Skriptsprachen-448a7d3303561035df18267c6ca1e5d9df55c049.zip | |
Create stoplist hash and test it
| -rw-r--r-- | Aufgabe5/searchengine.pm | 59 | ||||
| -rw-r--r-- | Aufgabe5/skript2.pl | 42 |
2 files changed, 101 insertions, 0 deletions
diff --git a/Aufgabe5/searchengine.pm b/Aufgabe5/searchengine.pm new file mode 100644 index 0000000..9a1690b --- /dev/null +++ b/Aufgabe5/searchengine.pm @@ -0,0 +1,59 @@ +# +#=============================================================================== +# +# FILE: searchengine.pm +# +# DESCRIPTION: +# +# FILES: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Stefan Suhren (su), suhren.stefan@fh-swf.de +# ORGANIZATION: FH Südwestfalen, Iserlohn +# VERSION: 1.0 +# CREATED: 02.12.2015 14:29:44 +# REVISION: --- +#=============================================================================== +package searchengine; + +use strict; +use warnings; +use utf8; + +# use common import function +use Exporter; + +# enforce utf-8 mode +binmode (STDIN, ":encoding(UTF-8)"); +binmode (STDOUT, ":encoding(UTF-8)"); +binmode (STDERR, ":encoding(UTF-8)"); +use open ":encoding(UTF-8)"; + +# add exporter as a parent for this package. +our @ISA= qw( Exporter ); + +# these CAN be exported. +our @EXPORT_OK = qw( buildStoplist ); + +# these are exported by default. +our @EXPORT = qw( buildStoplist ); + +sub buildStoplist { + my ( $stoplistFileName, $stoplist ) = @_; + + defined $stoplistFileName or die "StoplistFile must be supplied."; + defined $stoplist or die "Stoplist hash must be supplied."; + + open my $stoplistFile, '<', $stoplistFileName + or die "$0 : failed to open input file '$stoplistFileName' : $!\n"; + + while( my $word = <$stoplistFile> ) + { + chomp $word; + $stoplist->{$word} = ''; + } + + close $stoplistFile + or warn "$0 : failed to close input file '$stoplistFileName' : $!\n"; + +} ## --- end sub buildStoplist diff --git a/Aufgabe5/skript2.pl b/Aufgabe5/skript2.pl new file mode 100644 index 0000000..92897b7 --- /dev/null +++ b/Aufgabe5/skript2.pl @@ -0,0 +1,42 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: skript2.pl +# +# USAGE: ./skript2.pl +# +# DESCRIPTION: +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Stefan Suhren (su), suhren.stefan@fh-swf.de +# ORGANIZATION: FH Südwestfalen, Iserlohn +# VERSION: 1.0 +# CREATED: 02.12.2015 13:40:46 +# REVISION: --- +#=============================================================================== + +use strict; +use warnings; +use utf8; + +# For dumping data +use Data::Dumper; + +# Add own module +use searchengine; + +# enforce utf-8 mode +binmode (STDIN, ":encoding(UTF-8)"); +binmode (STDOUT, ":encoding(UTF-8)"); +binmode (STDERR, ":encoding(UTF-8)"); +use open ":encoding(UTF-8)"; + +my $stoplistFile = "stoplist.txt"; +my %stoplist; + +buildStoplist($stoplistFile, \%stoplist); + +print Dumper(\%stoplist); |
