Re: help regex and substitutions
- From: john swilting <john.swilting@xxxxxxxxxx>
- Date: Fri, 31 Aug 2007 19:02:03 +0200
Jim Gibson wrote:
In article <46d83c60$0$27378$ba4acef3@xxxxxxxxxxxxxx>, john swiltingthe book is programmation en perl 3eme edition
<john.swilting@xxxxxxxxxx> wrote:
I recopied the chaphitre 5
In what book?
#!/usr/bin/perl -w
use warnings; # preferred these days
use strict;
use diagnostics;
my @conf = ('XferMethod',
'rsync',
'XferLogLevel',
'1',
'RSyncShare',
'___1___',##they is these 2 pattern
'ClientNameAlias',
'___2___');##they is pattern
print @conf,"\n";
my @substitution = @conf;
my $motif =qr/___[1-9][0-9]?___/is;
my @regexes = ();
my @motif = ();
The array @motif is empty.
foreach $motif ( @motif ) {
push @regexes, qr/$motif/;
}
You are iterating over the empty array @motif, assigning each value
therein to the variable $motif. At the end of this loop, since @motif
has no values, the array @regexes will also be empty.
Perhaps you want, instead of the loop, the following:
push( @regexes, $motif );
foreach my $elem ( @substitution ) {
foreach my $re ( @regexes ) {##the loop however turns
well#scalar(@regexes
if ( $elem =~ /$re/) {##one do not arrive to this line
print "$elem egal $re\nentrer la valeur\n";
chop ($elem =<STDIN>);
print "nouvelle valeur de",$elem,"\n";
}
}
}
The inner statements of the loop on @regexes will never be executed,
because @regexes has no values.
with the push (@regexes,$motif)
the substitution is well
how to make to improve my code... I look at closely the precis examples
handbook O reilly
.
- Follow-Ups:
- Re: help regex and substitutions
- From: john swilting
- Re: help regex and substitutions
- References:
- help regex and substitutions
- From: john swilting
- Re: help regex and substitutions
- From: Jim Gibson
- help regex and substitutions
- Prev by Date: Re: Compare Dates
- Next by Date: Re: help regex and substitutions
- Previous by thread: Re: help regex and substitutions
- Next by thread: Re: help regex and substitutions
- Index(es):