Perl Monk, Perl Meditation | |
PerlMonks |
Drop middle part in a substitutionby James LiGate (Initiate) |
on Jan 26, 2004 at 17:58 UTC ( [id://324199]=perlquestion: print w/replies, xml ) | Need Help?? |
James LiGate has asked for the wisdom of the Perl Monks concerning the following question:
I suspect this is a dead-simple Perl newbie question (and I'm a dead-simple Perl newbie! :o) ), but darned if I can work it out.
I need to process filenames in the format filename.randomcharsEXT where EXT is a three-letter extension of any case (e.g., gif, Jpg, TXT...) and randomchars is guaranteed not to contain a period or any "special" characters. For an input of filename.randomcharsEXT the output needs to be filename.EXT... in other words, I need to drop the random characters between the dot and the extension.
This would be straightforward to do across multiple statements, but I'm thinking I should be able to do it with a single s/// and some thoughtful RE. Darned if I can noodle out the syntax, though. Can anyone point me to some references or examples? Nothing I've found in my search so far has helped.
Thanks!
Back to
Seekers of Perl Wisdom
|
|