in reply to Treating a variable as a variable in a regular expression?
Nope, I doubt this! Even without being able to test the code you posted. (did you?)
memcpy should be deleted now.
My best guess is that in your real code $function_used doesn't contain what you think it should.
Maybe a problem with scoping?
> So how can one solve this? !!!!!!!!!!!! I solved this by removing the global identifier. !!!!!!!!!!!!
Your keyboard is broken, maybe that's the problem?(...??????????)
:)
Cheers Rolf
(addicted to the Perl Programming Language)
now I can test, the code you posted explicitly informs you about the wrong semicolon:
> perl $function_used = "memcpy"; $function_call = "memcpy(a, b, sizeof(a));" $function_call =~ s/$function_used//g; Scalar found where operator expected at - line 3, near "$function_call +" (Missing semicolon on previous line?) syntax error at - line 3, near "$function_call " Execution of - aborted due to compilation errors.
and the corrected code doesn't have any of your imagined "problems"
> perl $function_used = "memcpy"; $function_call = "memcpy(a, b, sizeof(a))"; $function_call =~ s/$function_used//g; print $function_call; __END__ (a, b, sizeof(a))
so I think you should better take a look into How (Not) To Ask A Question :)
|
|---|