CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
I need help with a "simple" code formatter

 



drone01
Deleted

Jun 7, 2000, 4:25 PM

Post #1 of 2 (321 views)
I need help with a "simple" code formatter Can't Post

I am writing a simple code formatter:

if ( i == 0 ) {

if ( i == 0 )
{

Using perl how can I align the new "{" ?

How do I count the leading spaces before the "if" statement ?


dws
Deleted

Jun 8, 2000, 10:31 AM

Post #2 of 2 (321 views)
Re: I need help with a "simple" code formatter [In reply to] Can't Post

Try some variation on the following:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


s/^(\s*)(if\s*?\(.+?\)\s*?){$/"$1$2\n" . pad(length($1)) . "{"/e;

sub pad {
my $width = shift;
" " x $width;
}
</pre><HR></BLOCKQUOTE>


[This message has been edited by dws (edited 06-08-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives