pawarr has asked for the wisdom of the Perl Monks concerning the following question:

I wanted to add the code of string matching for the string 'EDA' to this code of file parsing. The code is provided below. Please Help.

#!/usr/bin/perl use strict; use warnings; open(my $fh,'data4.txt'); while(my $row = <$fh>){ chomp $row; print "$row \n"; }

Replies are listed 'Best First'.
Re: Pattern String Matching while parsing a file
by Laurent_R (Canon) on Jul 07, 2016 at 12:25 UTC
    For a simple literal match in a string, look at the index builtin function.

    As a side note, please note that it is probably unnecessary to chomp your input line if you're just going to add "\n" to it immediately after.

Re: Pattern String Matching while parsing a file
by Anonymous Monk on Jul 07, 2016 at 09:38 UTC
Re: Pattern String Matching while parsing a file
by pme (Monsignor) on Jul 07, 2016 at 13:47 UTC
    #!/usr/bin/perl use strict; use warnings; open(my $fh,'data4.txt'); while(<$fh>){ print if /EDA/; }