Nathan_84 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; print 'Enter a File name: '; chomp (my $file = <STDIN>); die "$file can't be found\n" unless -e $file; print 'Enter a search pattern: '; chomp (my $pattern = <STDIN>); open (F, '<', $file) || die $!; my @lines = <F>; my $cnt = @lines; my $found = 0; foreach my $line (@lines) { print $line and $found++ if $line =~ /\Q$pattern\E/; } print "\nTotal lines matched: $found\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: case sensitive addition
by Limbic~Region (Chancellor) on May 14, 2010 at 03:05 UTC | |
by murugaperumal (Sexton) on May 14, 2010 at 04:18 UTC | |
by Nathan_84 (Acolyte) on May 14, 2010 at 22:46 UTC | |
|
Re: case sensitive addition
by JavaFan (Canon) on May 14, 2010 at 09:51 UTC |