using scalar as an operator



what is a correct way to use a variable as an operator ?

i thought the following could work, but i get a syntax error on the
matching line.

my $regex = 'word';
my $modifier = 'i';
my $string = 'a string that has Words in it';

if($string =~ /$regex/$modifier){
print "match\n";
}

Thanks,

--

Jeremy Kister
http://jeremy.kister.net./
.



Relevant Pages

  • Including in VC6 project - compile errors
    ... C2059: syntax error: 'string' ... not a UDT or reference to a UDT. ... if applied using infix notation) ...
    (microsoft.public.vc.stl)
  • Re: VFP 9: Line Parsing
    ... This does not work, but because of that you won't need to consider source code that has && within a string literal, no matter where within the string, VFP insist on && being the start of a line end comment and therefore? ... The syntax highlighter of VFP does not color this correctly! ... Well, VFPs parser then can't determine, if the command or the comment would continue, so it does define this as syntax error. ...
    (microsoft.public.fox.programmer.exchange)
  • RE: run append query from form
    ... but now I get an syntax error in the FROM clause: ... Private Sub Command1_Click ... Dim strSQL As String ... Dim tbl_new As String ...
    (microsoft.public.access.formscoding)
  • Re: ML line number
    ... "SYNTAX ERROR IN LINE #" but i cannot seem to manipulate ... the zero page pointer for the current line number the error occured ... ;now we have our string pointed by AY, usually $0100, but just to be sure... ... sta $fb ...
    (comp.sys.cbm)
  • Re: Search for a record based on one of two fields
    ... Afraid it still does not work - it would appear to be a syntax error (the ... text comes up in red and the compiler reports a syntax error) ... > Dim stLinkCriteria As String ...
    (microsoft.public.access.formscoding)