Home: Perl Programming Help: Beginner:
Need help regarding parsing out put



sandeepda
New User

Jan 17, 2013, 3:11 AM


Views: 1561
Need help regarding parsing out put

I am executing a command it is returning me something like this

name ip port
------------------------------------
http-listener-1 * 6712
http-listener-2 * 8709

Code
 
I have a subroutine getListenerName($porttobeChecked)

This subroutine returns me the name of the listener if i pass a port.

Eg:If $porttobechecked=6712 I want to return an array a[0]=TRUE and a[1]=http-listener-1(listener name)

If port to be checked is 4516..I want to return an array a[0]=FALSE and a[1]=null

How can i parse this output.Any help appreciated?


Laurent_R
Veteran / Moderator

Jan 17, 2013, 5:02 AM


Views: 1553
Re: [sandeepda] Need help regarding parsing out put

I don't quite understand what you want. Are yau asking how to retrieve the values returned by the subroutine?

If such is the case, simply do something like this:


Code
my ($valid, $listener) = getListenerName($porttobeChecked) ;


If not, please explain further.