I know I should be able to figure this out, but I'm kind of "code blind" at this point. I need to match "for(", but not if it is preceeded by anything other than whitespace or the beginning of the line. I can easily match the whitespace/non-whitespace, but I can't seem to figure out the "or" BOL part. Here's basic snippet of what I'm trying to do:
#!/usr/bin/perl -w
use strict;
use diagnostics;
my $line = 'some_for($var)'; #don't match
$line = ' for($var)'; #match
$line = 'for($var)'; #match
if ($line =~ /\s+(for\()/gi) {
print 'match';
}
Changing \s+ to \s* obviously makes it match the BOL, but it also makes it match the non-whitespace also.