#!/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?
yes i have run it and below is the kind of output i get (original input all lower case except capitalised tags and for SCTN: line which is mixed case): [...]
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 have the script in the Perl/bin directory because it does not run if I have it anywhere else. Also I run it as #!/usr/bin/perl -w because #!/usr/bin/perl -p freezes my MS-DOS prompt.
So you have changed my program, removing the -p switch. Have you read about the switch you removed? See perlrun(1) manpage: http://www.perldoc.com/perl5.8.0/pod/perlrun.html#-p
-p causes Perl to assume the following loop around your program, which makes it iterate over filename argu- ments somewhat like sed:
LINE: while (<>) { ... # your program goes here } continue { print or die "-p destination: $!\n"; }
[...]
I have no experience with Perl under DOS, so it might be related to CRLF or some other issues as well, but just in case, did you run my program as:
program input.txt > output.txt
or in some different way? It's a filter, so it reads its input on STDIN or from files given as arguments, and prints the output on STDOUT. Read about the diamond operator (the null filehandle) in perlop(1) manpage:
http://www.perldoc.com/perl5.8.0/pod/perlop.html#I-O-Operators
The original input is a file called test1.txt and the output is a file called test3.txt
The whole program is as follows: [...]
You can't put part of my program anywhere into your code to make it do whatever you want (even Perl has a DWIM-wise limit). It only works in the same context, i.e. when it's executed for every line of input, having a single line of input in $_ every time it is run.
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;
I get no result with any of this.
Of course you don't get any results if you remove the -p switch which is absolutely essential for such a filter. Every program I wrote for you is correct, but when you change them, they obviously might stop being correct any more.
-zsdc.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]