Front page | perl.beginners |
Postings from May 2012
Why not match?
Thread Next
From:
Xi Chen
Date:
May 19, 2012 10:04
Subject:
Why not match?
Message ID:
CAPcTa_BLExY1w-Kmuwq7Mp+q-ADBZsBrWfnfj3xfDA3EsGhVNQ@mail.gmail.com
Hello guys,
I have a simple code, but it doesn't work and don't know why. Please see it
below:
Input file: 1.txt which including number and letter "o" in one line.
10o10o10
Wanted output file: 2.txt in which 10 represent 10 dots and o is replaced
by letter "x".
..........x..........x..........x
The perl code I wrote is below:
#!/usr/bin/perl
use strict;
use warnings;
while(<>){
chomp;
if(/^10o|o10o|o10\z/){
s/10/.………/g;
}
s/o/x/g;
print"$_\n";
}
And the output file is like ".???x.???x.???" , So patter matching doesn't
work. Don't know why. Could you please give me some suggestion? Thank you
so much!
Xi
Thread Next
-
Why not match?
by Xi Chen