in reply to Need help with s///

At this point you already have your answer, but I wanted to point out something that would have helped you find the answer faster: check your s/// call for success.
$a =~ s/\Q$$NETOBJ.// or die "$a is not right";
UPDATE: Abigail points out that the \Q won't prevent variable interpretation (damn) but that wasn't my point. My point was that you can only be sure a regex matched something if you check. To make Abigail happy I give you:
$a =~ s/\$\$NETOBJ\.// or die "$a is not right";

Replies are listed 'Best First'.
RE: RE: Need help with s///
by Abigail (Deacon) on Jul 15, 2000 at 02:25 UTC
    Actually, that would not have helped at all. The \Q will turn off interpretation of regular expression meta characters, but it will not prevent interpolation to happen. Hence, with use strict; in effect, the thing would still not compile, and without strict $$NETOBJ would be the empty string (warnings were disabled - so you don't get that error message), and the substitution would successfully remove the dot. Hence, the die would not happen.

    -- Abigail

RE: (2) Need help with s/// ( $! )
by ybiC (Prior) on Jul 15, 2000 at 17:08 UTC
    I believe that "$!" would make the "or die" even better, by providing information on why the regex didn't check.

    If so, that gives you:

    $a =~ s/\$\$NETOBJ\.// or die "$a is not right: $!";