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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to