in reply to Is it possible to store an arthimetric operator in a variable?
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.$num = 2; while (<>) { if ( /(\A|\D)$num(\D|\Z)/ ) { print "match\n"; } }
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
|
|---|