stevieb has asked for the wisdom of the Perl Monks concerning the following question:
I'm doing an overhaul on one of my modules (I'm running v5.22.0) and am hitting "Unescaped left brace in regex is deprecated" in a mock script meant to be transformed into a unit test. The offending line is the fourth-from-last, because $_ has a { in it.
How can I escape or otherwise work around this issue, so it'll be backward and forward compatible?
#!/usr/bin/perl use warnings; use strict; use File::Copy; use Tie::File; my $f = 't/sample.data'; my $wf = 't/write_sample.data'; copy($f, $wf); tie my @wfh, 'Tie::File', $wf; for (@wfh){ if (/sub seven/){ $_ =~ s/seven/xxxxx/; } } untie @wfh; open my $wfh, '<', $wf or die "Can't open test written file $wf: $!"; open my $fh, '<', $f or die "Can't open original test file $f: $!"; my @wf = <$wfh>; my @f = <$fh>; for (@f){ if (! grep /$_/, @wf){ print "$_\n"; } }
-stevieb
|
|---|