|
Answer» i am new to perl (i should say, i've never even looked at a perl script before today), but i do have a PROGRAMMING background...
so, we have a script that, among other things, takes a .doc file and changes the extension to .htm...there is an issue, however, with parentheses...so i wanted to added a little snippet that finds the parentheses and removes them...the piece i added apparently does not WORK...
what do you think i should change?
Code: [Select]sub convertWordDoc { my $htmDoc, $tempDir, $cmdLine; $htmDoc = $File::Find::name; $htmDoc =~ s/\.doc$/\.htm/i;
################################### # # Added to SEARCH and remove ( and ) # ################################### $htmDoc =~ s/[()]//g; ################################### # # End addition # ################################### convert2htm($File::Find::name, DELETE_SOURCE_DOC, DELETE_FILES_DIR); -e $htmDoc or die "word2htm failed on $File::Find::name"; } think i may have it...gotta test it though:
$htmDoc =~ s/[\(\)]//g;SORRY there aren't too many Perl whizkids around here..... no prob...new here and the last question i had i got a great response, so i figured i'd try this one too...Perl wizard here. Probably have figured this out by now or moved on but just in case I thought I'd offer my suggestion since I work with Perl every day and love Perl questions!
Your suggested regex should definitely locate and replace any parentheses. Always need to escape (use backslash) for special characters such as these. Otherwise it's going to try to use them as a function such as in this case capturing whatever is in-between the parentheses.
QUOTE $htmDoc =~ s/[\(\)]//g;
If you have any other Perl / Regex questions always feel free to hit me up.thanks for the reply...yes, i think that regex worked, but for some reason instead of looping through all the documents, it only modified the first and then stopped...if i remove that regex, it loops through all (without any modification of parentheses of course)...Hmm will would need to see your whole program and not just the subroutine to see why that could be happening.k, that will have to wait until Monday as i'm out of the office until then...if you don't mind checking back then i'd appreciate it....
|