I solved this by removing the global identifier. !!!!!!!!!!!!

No, you solved it by making the incomplete statement
    $function_call = "memcpy(a, b, sizeof(a));"
(no ; terminates the statement) into a complete statement (by adding a ; and then not mentioning it to anyone, possibly even including yourself ;).

c:\@Work\Perl>perl -wMstrict -le "my $function_used = 'memcpy'; my $function_call = 'memcpy(a, b, sizeof(a));'; $function_call =~ s/$function_used//g; print qq{'$function_call'}; " '(a, b, sizeof(a));'

(I'm assuming that by 'problem', you mean the fact that the OPed code will not compile.)

Update: If there's any chance that  $function_used may contain regex metacharacters, it's a very good idea to use quotemeta on it at some point, e.g.:
    $function_call =~ s/\Q$function_used\E//g;


In reply to Re: Treating a variable as a variable in a regular expression? by AnomalousMonk
in thread Treating a variable as a variable in a regular expression? by parkinglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.