Link to home
Start Free TrialLog in
Avatar of jovanplavsic
jovanplavsic

asked on

reagrding Matching scalars

Hi everybody,

I have two questions. I have input that I have to sort from a command that I issue on a router. here it is


avlist = base_CD02S1A,       networking_CD02S1A      framerelay_CD02S1A
atmNetworking_CD02S1A  

now I need to check that "avlist = base_CD02S1A is present so I do this

$os_ver='avlist = base_CD02S1A';
($output)=$connection->waitfor($prompt)
print $output;

if($os_ver=~/$output/){
do this
else{
this}

I am not geting the right match is there a better way to mathc this with regular expressions so only the input that I need is retrieved into $output or is am I matching this wrong.
Thank you

ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jovanplavsic
jovanplavsic

ASKER

thank you
Also remember that you don't need a regex to find literal string matches. The index operator will do that.

if( index( $output, $os_ver) >= 0 ) {

For a case-insensitive match, you could applyt the 'lc' operator to both operands, but by that time, it may no longer be any faster than a regexp match.