in reply to finite automata
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: finite automata
by davorg (Chancellor) on Oct 02, 2001 at 16:10 UTC | |
by doc (Scribe) on Oct 02, 2001 at 22:36 UTC |