perl autoindent and elsif statements

In my hands the perl autoindent code almost works perfectly. But it doesn’t properly handle elsif statement. Anyone gotten that to work? For example, the current code indents as below:

if ( $x == 1 ) {    
    print "Hello World\n";     
    } elsif ( $x == 2 ) {     
        print "Something else\n";   
    }

but naturally we would like:

if ( $x == 1 ) {    
    print "Hello World\n";   
} elsif ( $x == 2 ) {    
    print "Something else\n";   
}

I’ve banged my head against those regular expression several times, but I just can’t figure out a way to get this to indent correctly.

Reply

  • You can use Markdown syntax to format and style the text.
  • You may link to images on this site using a special syntax
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.