in reply to Regex variables with delimiters
#!/usr/bin/perl # https://perlmonks.org/?node_id=11100208 use strict; use warnings; my $line = "/dev/sda4 6 Fri Apr 12 04:30:02 2019 +0100 /dumpx/DUMP4X +/var/level6/55 86.53 MB\n"; my $secondline = "/dumpx/DUMP4X/var/level6/55\n"; my $regex = quotemeta $secondline =~ tr/\n//dr; if( $line =~ $regex ) { print "matches\n"; } else { print "does not match\n"; }
|
|---|