![]() |
|
Just another Perl shrine | |
PerlMonks |
More Regexp Confusionby mdunnbass (Monk) |
on Feb 01, 2007 at 21:57 UTC ( [id://597839]=perlquestion: print w/replies, xml ) | Need Help?? |
mdunnbass has asked for the wisdom of the Perl Monks concerning the following question:
I posted a question similar to this one last week, and got
some very helpful answers. But, since I didn't frame the question well,
I didn't get the answers I was looking for
Scenario: $foo is from uc(chomp($foo = <STDIN>));, and is only English letters. However, let's say $foo = 'GOAT'; the file I'm looking through doesn't have 'GOAT' anywhere, but it does have asdfGxxOxxAxxTqwerty and other permutations. I want to make: asdfG..O..A..Tqwerty become: 'asdf'.$stuff1.'GxxOxxAxxT'.$stuf2.'qwerty' And before I can mislead you or anything, I don't care if the xx's are xx or if the qwerty is qwerty. They could be anything matching [^A-Z]. I just want to ignore them and leave them undisturbed. Essentially, I want to do this globally, and the only change I want to make to the text file is adding $stuff1 and $stuff2. I've tried various things, all to abysmal and spectacular failure. I think it should be something along the following lines, but I know as is, this is wrong:
Of course, I recognise that the $1 there correspoonds to the GOAT and not the GxxOxxAxxT, but I am at a loss as to how to proceed. Any thoughts? I know that many people responded to my OP suggesting something like:
..and that the method I proposed above is more of the inverse... I just wasn't able to get the original suggestions to work for me, and I attributed it to me not describing the problem well enough.
Thanks for any insights
Back to
Seekers of Perl Wisdom
|
|