On Jul 6, 9:31 am, [EMAIL PROTECTED] (Gunwant Singh) wrote:

> Thnx for your solution, although I did not get the complete solution as
> explained in your earlier email.
> Can you please simplify your explanation. Also, would it not be possible
> w/o making wordlist.unified.
>
> Thanks.

     1  #!/usr/local/bin/perl
     2  use warnings;
     3  use strict;
     4
     5  my $this = <>;
     6  chomp $this;
     7
     8  my $that = search_data( $this );
     9
    10  print defined $that? "found: '$that'\n": "'$this' not found.
\n";
    11
    12  sub normalize { join "", sort split "", $_[0] }
    13  sub search_data {
    14      my( $want ) = @_;
    15      $want = normalize $want;
    16      while( <DATA> ) {
    17          chomp;
    18          return $_ if $want eq normalize $_;
    19      }
    20      return;
    21  }
    22
    23  __DATA__
    24  alpha
    25  alpha1
    26  beta
    27  betaze
    28  gamma
    29  gamman
    30  gammano

--
Brad


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to