freelanceprogrammers.org Forum Index » Perl

pattern searching


View user's profile Post To page top
junoon_hai_m... Posted: Fri Jun 24, 2005 8:25 am


Joined: 27 Apr 2005

Posts: 4
pattern searching
This is my goal, if i have an input file:


BEGIN----------
Smith
Johnathan
Smiths
Mona
Moynaham
END------------


i want to generate a minimum match so that with the minimum match
string, each entry can be identified. the output would be:


BEGIN----------
Smith - Smith
Smiths - Smiths or hs
Mona - Mon or ona
Moynaham - Moy or nah or aha or ham
END------------


Is there any built-in function to do such analysis in perl?
Reply with quote
Send private message
View user's profile Post To page top
ravish_leo Posted: Fri Jun 24, 2005 6:07 pm


Joined: 24 Jun 2005

Posts: 3
pattern searching
can u give little more detail about ur qst?
U have not mentioned that how u will get this input,
is this dynamic or static?
How u want your output file ?

--- junoon_hai_mujhe <junoon_hai_mujhe@...>
wrote:

> This is my goal, if i have an input file:
>
>
> BEGIN----------
> Smith
> Johnathan
> Smiths
> Mona
> Moynaham
> END------------
>
>
> i want to generate a minimum match so that with the
> minimum match
> string, each entry can be identified. the output
> would be:
>
>
> BEGIN----------
> Smith - Smith
> Smiths - Smiths or hs
> Mona - Mon or ona
> Moynaham - Moy or nah or aha or ham
> END------------
>
>
> Is there any built-in function to do such analysis
> in perl?
>
>
>
>
>
>
>




____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
merlynstoneh... Posted: Fri Jun 24, 2005 6:46 pm


Joined: 21 May 2004

Posts: 44
pattern searching
>>>>> "junoon" == junoon hai mujhe <junoon_hai_mujhe@...> writes:

junoon> This is my goal, if i have an input file:
junoon> BEGIN----------
junoon> Smith
junoon> Johnathan
junoon> Smiths
junoon> Mona
junoon> Moynaham
junoon> END------------


junoon> i want to generate a minimum match so that with the minimum match
junoon> string, each entry can be identified. the output would be:


junoon> BEGIN----------
junoon> Smith - Smith
junoon> Smiths - Smiths or hs
junoon> Mona - Mon or ona
junoon> Moynaham - Moy or nah or aha or ham
junoon> END------------


junoon> Is there any built-in function to do such analysis in perl?

I believe you`re looking for Text::Abbrev, and yes, that`s a core
module. "perldoc Text::Abbrev" for more information.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Reply with quote
Send private message
View user's profile Post To page top
junoon_hai_m... Posted: Fri Jun 24, 2005 9:46 pm


Joined: 27 Apr 2005

Posts: 4
pattern searching
this input will be in a file and would be a one time deal.
the output file would be like

Smith,Smith
Smiths,hs
Mona,Mon,ona
Moynaham,Moy,nah,aha,ham


--- In perl_official@yahoogroups.com, Ravish Kumar <kumarabish@y...>
wrote:
> can u give little more detail about ur qst?
> U have not mentioned that how u will get this input,
> is this dynamic or static?
> How u want your output file ?
>
> --- junoon_hai_mujhe <junoon_hai_mujhe@h...>
> wrote:
>
> > This is my goal, if i have an input file:
> >
> >
> > BEGIN----------
> > Smith
> > Johnathan
> > Smiths
> > Mona
> > Moynaham
> > END------------
> >
> >
> > i want to generate a minimum match so that with the
> > minimum match
> > string, each entry can be identified. the output
> > would be:
> >
> >
> > BEGIN----------
> > Smith - Smith
> > Smiths - Smiths or hs
> > Mona - Mon or ona
> > Moynaham - Moy or nah or aha or ham
> > END------------
> >
> >
> > Is there any built-in function to do such analysis
> > in perl?
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
> ____________________________________________________
> Yahoo! Sports
> Rekindle the Rivalries. Sign up for Fantasy Football
> http://football.fantasysports.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
siddy_tow Posted: Sat Jun 25, 2005 4:10 pm


Joined: 25 Jun 2005

Posts: 1
pattern searching
Hi ALL

I am facing a problem with the NET::TELNET module. I am telnetting to a linux
box and there I am trying to run perl script which actually is a expect script.
So now the problem is that when the perl expect script is running remotely I am
supposed to execute a command and wait for its completion and then execute the
next command when I get the prompt. The problem is that I am not able to get the
complete command execution and hence the next prompt. I wonder what the problem
is, is it like the telnet window is smaller or the output buffer allocated to
the telnet session through the perl module is small. Can anyone explain.
I have copied some part of the code I hope it helps you.

windows pc telnet code
$telnet_box->open("$host") ||
die "Failed to connect to $host $!";
$telnet_box->login($user_name, $password) ||
die "Failed to log onto $host. The username or password is wrong$!";
@$lines = $telnet_box->cmd("perl expect_execute.pl");

Linux box expect script code:

$exp_inst->log_file("$templog", "w");
$exp_inst->expect($timeout,
[ `-re` , $prompt,
sub {
my $fh = shift;
$fh->send("$command
");
}
],
[ timeout =>
sub {
my_die "unable to get the prompt $prompt";
}
]
);

Output :
prompt> command


More ...

Expected:
prompt> command
xyz
yy
prompt>


Thanks in advance


---------------------------------
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
merlynstoneh... Posted: Thu Jun 30, 2005 12:25 pm


Joined: 21 May 2004

Posts: 44
pattern searching
>>>>> "sid" == sid tow <siddy_tow@...> writes:

sid> I am facing a problem with the NET::TELNET module.

If you want to run expect-like actions, don`t use Net::Telnet. Use
the Expect module (in the CPAN.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help