in reply to search a string in a non-regular file
use strict; use warnings; use Test::More; my @good = ( '* leading asterisk', 'trailing asterisk *', 'multiple *** asterisk' ); my @bad = ( 'foo', '', '^' ); my $re = qr/\*/; plan tests => @good + @bad; for my $str (@good) { like ($str, $re, "$str matched"); } for my $str (@bad) { unlike ($str, $re, "$str not matched"); }
See How to ask better questions using Test::More and sample data for how to write tests like this and formulate your question to fully illustrate the problem.
I happened to come across an issue of finding a string in 'non-regular' log file.
Define "non-regular". Do you just mean the lines have different lengths?
|
|---|