Re: help regex and substitutions
- From: Klaus <klaus03@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 11:20:32 -0700
On Aug 31, 7:15 pm, john swilting <john.swilt...@xxxxxxxxxx> wrote:
how to make to improve my code...
#!/usr/bin/perl -w
use strict;
use diagnostics;
If you can afford, get rid of the "use diagnostics" to improve
execution speed.
use warnings;
my @conf = ('XferMethod',
'rsync',
'XferLogLevel',
'1',
'RSyncShare',
'___1___',
'ClientNameAlias',
'___2___');
print @conf,"\n";
my @substitution = @conf;
my $motif =qr/(___[1-9][0-9]?___)/is;
my @regexes = ();
##my @motif = ();
##foreach $motif ( @motif ) {
## push (@regexes,qr/$motif/);
## }
You could remove the commented out code altogether from your program,
it is confusing.
push (@regexes,$motif);
foreach my $elem ( @substitution ) {
foreach my $re ( @regexes ) {
if ( $elem =~ /$re/) {
print "$elem egal $re\nentrer la valeur\n";
chop ($elem =<STDIN>);
You could use chomp instead of chomp.
perldoc -f chomp
This safer version of chop removes any trailing string that
corresponds to the current value of $/
print "nouvelle valeur de",$elem,"\n";
}
}
}
.
- References:
- help regex and substitutions
- From: john swilting
- Re: help regex and substitutions
- From: Jim Gibson
- Re: help regex and substitutions
- From: john swilting
- Re: help regex and substitutions
- From: john swilting
- help regex and substitutions
- Prev by Date: get memory percent usage info
- Next by Date: FAQ 2.6 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
- Previous by thread: Re: help regex and substitutions
- Next by thread: Compare Dates
- Index(es):
Relevant Pages
|
|