in reply to Is it possible to store an arthimetric operator in a variable?

Taking the tack that you may have given an oversimplified problem statement, would this do what you intended?
$num = 2; while (<>) { if ( /(\A|\D)$num(\D|\Z)/ ) { print "match\n"; } }
Here (\A|\D) matches the start of the string, or a non-digit. Likewise, (\D|\Z) matches a non-digit or the end of the string.

If you have rules for what surrounds your $num value in the input string, you may better limit your search.

-QM
--
Quantum Mechanics: The dreams stuff is made of