in reply to searching string from one file in another
Calling the files in your code $file2 and $file1 doesn't help us to see which one is supposed to be "data" and which is supposed to be "search". Is this the sort of thing you are after:
#!/usr/bin/env perl use strict; use warnings; my $data = <<EOT; hostname banner exec EOT my $search = <<EOT; hostname XXXXX banner exec ********************************************************** +******************** banner exec</> banner exec This device belongs to the EOT for my $substr (split /\n/, $data) { for my $line (split /\n/, $search) { print "Matched '$substr' in '$line'\n" if index ($line, $subst +r) > -1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: searching string from one file in another
by Eily (Monsignor) on Feb 28, 2017 at 13:35 UTC |