[ create a new paste ] login | about

Link: http://codepad.org/jfxt1YOd    [ raw code | output | fork ]

Perl, pasted on Sep 19:
use strict;

my $fh       = *DATA;            # set the filehandle
my $pos      = tell $fh;         # store file pos

## Positive Matches

my @matched  = grep {/void [s|S]et[\w]+\(\s*.*string/} <$fh>;

print "Found: " . @matched . "\n";
print "Matches:\n @matched";


# Reset the position to use again
seek $fh, $pos, 0;

## Negative Matches

my @not_matched = grep {$_ !~ /void [s|S]et[\w]+\(\s*.*string/} <$fh>;

print "Found: " . @not_matched . "\n";
print "Not Matched:\n @not_matched";

__DATA__
viod setChanName(const std::string & chanName)     # Notice the misspelling
void setChanName(const std::string & chanName)
void setChanNameFont(const std::string & font)
void setOSDMessage(const std::string & osdMessage)
void setOSDMessageFont(const std::string & font)


Output:
1
2
3
4
5
6
7
8
9
Found: 4
Matches:
 void setChanName(const std::string & chanName)
 void setChanNameFont(const std::string & font)
 void setOSDMessage(const std::string & osdMessage)
 void setOSDMessageFont(const std::string & font)
Found: 1
Not Matched:
 viod setChanName(const std::string & chanName)     # Notice the misspelling


Create a new paste based on this one


Comments: