Code Comments
Programming Forum and web based access to our favorite programming groups.Ken Wolcott wrote:
> Hi;
Hello,
> I need to find Makefiles that contain a backslash line continuation
> character followed by a blank (or whitespace only) line. I tried a
> regular expression first but just couldn't get it right. I then tried
> comparing by a pair of strings, but that isn't right either.
>
> [snip code]
This will do what you want:
#!/usr/bin/perl
use strict;
use diagnostics;
while ( <> ) {
my $line_num = $.;
if ( /\\\s*$/ ) {
my $line_before;
if ( ( $line_before = <> ) =~ /^\s*$/ ) {
print "$ARGV has a backslash continuation to a following blank line at line
$line_num\n";
}
else {
$_ = $line_before;
redo;
}
}
}
__END__
John
--
use Perl;
program
fulfillment
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.