Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1834 connectés 

 


Dernière réponse
Sujet : [PERL] Explications sur un script SVP
Largo Voila, je comprends pas trop comment ce script marche:
sub parse_csv {
    my $text = shift;      # record containing comma-separated values
    my @new  = ();
    push(@new, $+) while $text =~ m{
        # the first part groups the phrase inside the quotes.
        # see explanation of this pattern in MRE
        "([^\"\\]*(?:\\.[^\"\\]*)*)",?
           |  ([^,]+),?
           | ,
       }gx;
       push(@new, undef) if substr($text, -1,1) eq ',';
       return @new;      # list of values that were comma-separated
}  
 
ça parse un fichier CSV en omettant les ',' qui sont entre double quote ( " ) et backslashées \,
c'est l'expression régulière que je comprends pas..., si vous pouviez m'aider et décomposer le script...
 
MERci. :hello:  
 :hello:  :hello:

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
Largo Voila, je comprends pas trop comment ce script marche:
sub parse_csv {
    my $text = shift;      # record containing comma-separated values
    my @new  = ();
    push(@new, $+) while $text =~ m{
        # the first part groups the phrase inside the quotes.
        # see explanation of this pattern in MRE
        "([^\"\\]*(?:\\.[^\"\\]*)*)",?
           |  ([^,]+),?
           | ,
       }gx;
       push(@new, undef) if substr($text, -1,1) eq ',';
       return @new;      # list of values that were comma-separated
}  
 
ça parse un fichier CSV en omettant les ',' qui sont entre double quote ( " ) et backslashées \,
c'est l'expression régulière que je comprends pas..., si vous pouviez m'aider et décomposer le script...
 
MERci. :hello:  
 :hello:  :hello:

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)