REGEX help with substitute
- From: "Bill" <bill636363@xxxxxxxxx>
- Date: Wed, 28 Sep 2005 16:37:02 GMT
Hello All,
I'm not so new to perl as I am to Regular Expressions and useing the s///;
substitute operator.
Where I am running into a problem is fixing a log file program that reads in
the log file and splits it on the spaces.
The program works fine untill I hit a user who somehow in the past managed
to get a username with a space in it.
I have no control over user accounts and I just have to just deal with it.
So far I have found 2 out of about 2000 users have this problem.
My current fix is to rewrite the entire log file. 238 lines of code to do
this to root out and correct the offending usernames.
I figured a easy fix would be to use substitute inline with my current code
and not have to rewrite the file like so:
substitute $firsthalf $secondhalf with $firsthalf_$secondhalf
or
$_ =~ s/($firsthalf) ($secondhalf)/($firsthalf)_($secondhalf)/g;
1st am I correct that variables have to be like this ($???)
2nd is my regular expression correct. I downloaded a program to test regular
expressions but it cannot handle variables in it.
I will deal with the fact that I may have another user with
$firsthalf_$secondhalf later by doing some checking prior to the
substitution.
Thanks in advance for any and all help,
Bill
.
- Prev by Date: RE: WELCOME to beginners@perl.org
- Next by Date: Re: general retry function
- Previous by thread: Re: WELCOME to beginners@perl.org
- Next by thread: Anonymous Reference Question
- Index(es):
Relevant Pages
|
|