string checks

2001-08-23 Thread Robert_Collins

What is the best way in Perl to do the following?

Check $string to see if the following path is found /this is right/
If found anywhere in the string return 1, if not return 0.  The whole 
pattern must be found just like written.


Robert ( Kent ) Collins:  IBM Certified Solutions Expert
Cell Phone:  214.632.3940
DBA Intranet Site: http://ora3dba.i2.com/support
Major advancements in technology are indistinguishable from Magic


Re: string checks

2001-08-23 Thread Michael Fowler

On Thu, Aug 23, 2001 at 06:10:48PM -0500, [EMAIL PROTECTED] wrote:
 What is the best way in Perl to do the following?

Define best.  Is it fastest?  Most readable?  Most clever?


 Check $string to see if the following path is found /this is right/
 If found anywhere in the string return 1, if not return 0.  The whole 
 pattern must be found just like written.

I'd either use:

index($string, /this is right/) != -1

if I'm being frugal with CPU cycles, or

$string =~ m|/this is right/|

if I'm not, or if I prefer readability at that point.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]