bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trouble with perl indentation


From: na frederic
Subject: trouble with perl indentation
Date: Wed, 11 May 2005 11:30:49 +0200 (CEST)

there is a trouble when i try to indent the folowing
code, this is due to the search of a regexp containing
a  "}" in a file. 

Regards,
frédéric

----- bad indented code: -----------------------------
# pour chaque nom de fichier passé en paramètre.
foreach $arg (@ARGV)
{
        # si ce fichier existe
        if (-e $arg)
        {
                # on ouvre le fichier.
                open(FICHIERACT, "<" . $arg)
                        || die "Erreur " .  $arg . ", $!.\n";

                $action = $noname;
                while(<FICHIERACT>)
                {
                        
                        # si on trouve une ligne d'action 
                        # alors on calcul son nom est on l'ouvre.
                        if ($_ =~ /^action[ \t]+.*$/)
                        {       
                                $act_open = $vrai;
                                $action = &nom_action($_);
                                open(ACTION,">" .$action)                       
                                        || die "Erreur " .  $action . ", $!.\n";
                        }
                        
                        if ($act_open == $vrai)
                        {
                                syswrite(ACTION,$_,length($_));
                        } 
# >>>>> folowing line cause indent trouble: 
                        if ($_ =~ /^[ \t]*\`};$/)
        {
                $act_open = $faux;
                close ACTION;
        }
        }                       
        if ($act_open == $vrai)
        { 
                close ACTION;
        }
        close FICHIERACT;
}
else
{
        print "Warning $arg n'existe pas!";
}
}

----------- the corect indentation should be : -------

# pour chaque nom de fichier passé en paramètre.
foreach $arg (@ARGV)
{
        # si ce fichier existe
        if (-e $arg)
        {
                # on ouvre le fichier.
                open(FICHIERACT, "<" . $arg)
                        || die "Erreur " .  $arg . ", $!.\n";

                $action = $noname;
                while(<FICHIERACT>)
                {
                        
                        # si on trouve une ligne d'action 
                        # alors on calcul son nom est on l'ouvre.
                        if ($_ =~ /^action[ \t]+.*$/)
                        {       
                                $act_open = $vrai;
                                $action = &nom_action($_);
                                open(ACTION,">" .$action)                       
                                        || die "Erreur " .  $action . ", $!.\n";
                        }
                        
                        if ($act_open == $vrai)
                        {
                                syswrite(ACTION,$_,length($_));
                        } 
                        if ($_ =~ /^[ \t]*\`};$/)
                {
                                $act_open = $faux;
                                close ACTION;
                        }
             }                  
         if ($act_open == $vrai)
             { 
                         close ACTION;
             }
        close FICHIERACT;
        }
        else
        {
                print "Warning $arg n'existe pas!";
        }
}
---------------- end ---------------------------------


        

        
                
__________________________________________________________________ 
Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails ! 
Créez votre Yahoo! Mail sur http://fr.mail.yahoo.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]