To interpolate a variable as a regex instead of as a string literal, you need to wrap it in < >.
On Sat, Sep 15, 2018 at 4:09 AM ToddAndMargo <toddandma...@zoho.com> wrote: > On 09/15/2018 12:42 AM, ToddAndMargo wrote: > > Hi All, > > > > I am truing to use a variable inside a regex. > > > > This work (without the variable): > > $ p6 'my $x="6937-2.2.19882.exe"; if $x ~~ m/ .*? <<:\N**4>> "-" > > (.*?) ".exe" / {say "yes";}' > > yes > > > > I want to turn `<<:\N**4>>` into a variable: > > > > > > $ p6 'my $x="6937-2.2.19882.exe"; my $i="<<:\\N**4>>"; if $x ~~ m/ > > .*? $i "-" (.*?) ".exe" / {say "yes";}else{say "No"}; say "$i";' > > > > No > > <<:\N**4>> > > > > The double \\ is to get it past bash > > > > > > What am I doing wrong? > > > > Many thanks, > > -T > > never mind. It got just a bit too goofy. I switched > to .contains and sent myself a tag as to when the > first bunch was a random 4 digit number. > > > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > -- brandon s allbery kf8nh allber...@gmail.com