Re: Трава перл...фсем курить;-)

Yury Kopyl hrg на sama.ru
Чт Сен 25 07:58:07 CDT 2003


Hello, LaVei!
You wrote to "Samara (Russia) Perl Mongers" <samara-pm на mail.pm.org> on Thu,
25 Sep 2003 16:49:42 +0500:

  L>>> Как решить в одну строку это, я себе пока не представляю...
 L>>> поэтому если участники не против то критерием будет Benchmark?;-)

 YK>> http://search.cpan.org/search?query=wrap&mode=all - это? :))
 L> Чур CPAN непользоваться!!!:-))

"Как же так, Федор Михайлович"(С)Сеня Лютый

my $width=40;
my $text="A simple, easy to remember system for encoding integer
amounts can be very
useful. For example, dealers at flea markets put the
information about an item
on a card that they let potential buyers see. They find it
advantageous to
encode the amount they originally paid for the item on the
card.\nA good system
is to use a substitution code, in which each digit is
encoded by a letter. An
easy to remember 10-letter word or phrase, the key, is
chosen. Every '1' in the
value is replaced by the first letter of the key, every
'2' is replaced by the
second letter of the key, and so on. Every '0' is replaced
by the last letter of
the key. Letters that do not appear in the key can be
inserted anywhere without
affecting the value represented by the code.. This helps
to make the resulting
code much harder to break (without knowing the
key).\nCreate a class Substitute
that contains the method getValue that is given the
Strings key and code as
input and that returns the decoded value.";

my $format_str='^'.'>'x ($width-1)."~~\n";


foreach my $text (split (/\n/,$text)){

 $text=~s/^\s+//;
 $text=~s/\s+$//;

 formline ($format_str,$text);
 print $^A;
};



With best regards, Yury Kopyl.  E-mail: hrg на sama.ru




Подробная информация о списке рассылки Samara-pm