This will get you started:
#!/usr/bin/perl -w use strict; my $string = 'just another perl hacker'; # generate a lookup hash containing the words in our language # as the keys, we set the values to 1 with the ++ syntax # so as to define the keys which are all we use my %lang; do{ chomp; $lang{$_}++ }for <DATA>; # split the test string on whitespace to give us an # array that will contain all the 'words' where a # word is a character sequence my @bits = split /\s/, $string; # iterate over our word array seeing if they are # defined in our langugue specification for (@bits) { die "Word '$_' not in language!\n" unless defined $lang{$_}; } # if we have not died then all the words are OK print "Success, \$string only contains words in language!\n"; __DATA__ just another finite automaton perl hack
doc
print(s<>ecode?scalar reverse :p)
In reply to Re: finite automata
by doc
in thread finite automata
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |