*Please* CC the mailing list when you answer. I'm writing it so everyone on the list could learn something, not just to fix your program or solve your particular problem.

bis wrote:

Tnaks zsdc and JEGII.

--- zsdc <[EMAIL PROTECTED]> wrote:

It gives a syntax error. Maybe try this:

  #!/usr/bin/perl -p
  s/(\s)(.)/$1\u$2/g if/SCTN:/;

This capitalises the first letter of every word in the whole document.

No, it doesn't. Only the lines containing "SCTN:" Have you run it?


or instead of /SCTN:/ use /^SCTN:/

This doesn't do anything.


or /^\s*SCTN:/

Nor does this.

Well... Yes, it does. How did you run it, anyway?


I think the title of my query was misleading - what I
maybe should have said was "Uppercasing the first
letter and lowercasing all the other letters of every
word in a mixed case part of a string"?

This is much harder. It's easy to make the output like this:


I'Ve Been Reading O'Reilly Books

OR:

I've Been Reading O'reilly Books

but not:

I've Been Reading O'Reilly Books

which is correct. I suggest you to only uppercase characters, but if you have to also lowercase the other ones then try:

  #!/usr/bin/perl -p
  s/(\s)(\S+)/$1\L\u$2/g if/^\s*SCTN:/;

or

  #!/usr/bin/perl -p
  s/\b(\w+)/\L\u$1/g if/^\s*SCTN:/;

(and maybe add:

use locale;

at the beginning) and see which suits your needs better. You might find better examples in the Cookbook.

-zsdc.


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to