This works great with version 5's auto-hide command output mode.
Code: Select all
# DOS command should be:
# perl "c:\userdata\temp\textpad\findinfile.pl" "$File" "$Sel"
# Regex should be:
# ^([0-9]+):
# Line is \1
my $filename = $ARGV[0];
my $selection = $ARGV[1];
open (INFILE, "<$filename") || die "Failed to open $filename";
my @lines = (<INFILE>);
close INFILE;
if ($selection eq "") {
print "Selection is empty.\n";
exit 0;
} else {
print "$filename\n";
print "Searching for \"$selection\"\n";
print "\n";
}
my $linenum = 1;
foreach $line (@lines) {
chomp $line;
if ( $line =~ /${selection}/gi ) {
my $tmp = sprintf( "%03u", $linenum );
print "$tmp: $line\n";
}
$linenum = $linenum + 1;
}