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

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

$os_ver='avlist = base_CD02S1A';
print $output;

do 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

Who is Participating?
FishMongerConnect With a Mentor Commented:
Try reversing the logic on the pattern matching.

if ($output =~ /$os_ver/i){
jovanplavsicAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.