in reply to Re: What does this mean?
in thread What does this mean?

But I was expecting:
You did a case sensitive match for "Smith", so it correctly skipped over "smith".

You can try m{$search_term}i instead, for case ignoring matching.

BTW Do you have anything against slashes for regular expressions? It's the default, and it's what people are used to: /$search_term/i

Changing it without reason is unnecessarily obfuscating.

Replies are listed 'Best First'.
Re^3: What does this mean?
by Cuhulain (Beadle) on Mar 01, 2010 at 14:14 UTC
    BTW Do you have anything against slashes for regular expressions? It's the default, and it's what people are used to: /$search_term/i

    Changing it without reason is unnecessarily obfuscating.

    Far from obfuscating regexps, alternate delimiters to '/' can help to clarify. From perldoc perlre:

    Modifiers are usually written as "the /x modifier", even though the delimiter in question might not really be a slash.

    . . .

    You can use The /x modifier to break up your regular expression into (slightly) more readable parts.

    . . .

    Taken together, these features go a long way towards making Perl's regular expressions more readable.

    From the Perl Cookbook (1st ed.) Recipe 6.4 Commenting Regular Expressions:

    For aesthetics, the example uses alternate delimiters. When you split your match or substition over multiple lines, it helps readability to have matching braces. Another common reason to use alternate delimiters is when your pattern or replacement contains slashes, as in s/\/\//\/..\//g, alternate delimiters makes such patterns easier to read as in s!//!/../!g or s{//}{/../}g

    Slashes may be what most of us are used to seeing in single-line regexps, but alternate delimiters have their place too.

Re^3: What does this mean?
by desemondo (Hermit) on Mar 01, 2010 at 22:19 UTC
    You did a case sensitive match for "Smith", so it correctly skipped over "smith".
    You can try m{$search_term}i instead, for case ignoring matching.

    umm... yes. That was supposed to be a code example that one might use when posting in SoPW... So often there are questions that are unclear.

    When you have all 3 aspects of the problem
    1. real code that demonstrates the problem
    2. Expected Output
    3. Actual Output the OP recieves

    its far easier to figure out what they are trying to do and where they have come unstuck...

    BTW Do you have anything against slashes for regular expressions?
    No, not really, I just prefer using curlies. Each to their own I guess...

    Changing it without reason is unnecessarily obfuscating.
    I see your point.

    Update: Addressed bart's second point.
Re^3: What does this mean?
by biginingperl (Initiate) on Mar 01, 2010 at 13:25 UTC

    Thank you all for the support.
    I think much of the information on perl is present on perldocs..Thanks once agan...