vasanth.easyrider has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks
I have a requirement where i connect to 2 types of devices using Net::Telnet.

first type of device gets a prompt as follows -

newnetcool@BLR-ISP-ACC-RTR-73>

Note - there is a space after ">"


second type of device gets prompt as follows

RP/0/RSP1/CPU0:KNY-ISP-ACC-RTR-075#

how to give a single prompt with (or) condition in Net::Telnet so that it will work for both type of devices


please help me

Replies are listed 'Best First'.
Re: How to give prompt
by hippo (Archbishop) on Mar 16, 2018 at 13:19 UTC
Re: How to give prompt
by 1nickt (Canon) on Mar 16, 2018 at 12:02 UTC

    Hi, I don't know anything about your requirement or telnet prompts, but your question seems to be one about basic software design.

    You should write a module named something like MyConnect.pm containing the code that is used for all cases. Then you should write subclasses like MyConnect/SomeDevice.pm and MyConnect/OtherDevice.pm which contain the functions that are specific to each case. Then use the appropriate subclass in each case.

    See perlmod and many other resources, e.g. https://perlmaven.com/how-to-create-a-perl-module-for-code-reuse.


    The way forward always starts with a minimal test.