in reply to Re^3: Undefined Error
in thread Undefined Error

Actually, there is some issue with regex, where I am putting /^BIND$/ to match exact word, as there is another string "UNBIND".

is this not the right way to match exact string /^BIND$/? Please let me know if it is not.

Thanks,

Replies are listed 'Best First'.
Re^5: Undefined Error
by poj (Abbot) on Jun 15, 2013 at 15:46 UTC
    /^BIND$/ matches if that is the only word on the line.

    Try adding word boundaries \b like this ;

    while (<DATA>){ if (/\bBIND\b/){ print $_; } } __DATA__ this is a BIND sentence I have UNBIND in this one BIND as first word last word is BIND

    poj
Re^5: Undefined Error
by hdb (Monsignor) on Jun 15, 2013 at 15:46 UTC

    BIND seems to be surrounded by spaces, so /\sBIND\s/ should work. Your suggestion would only fit a string (or line) containing BIND and nothing else as the caret is signifying the start of the string (or line) and dollar the end of string (or line).