Forgive the ignorance...
perl -pe ' s/"/"/g; '
This there any reason that the above wouldn't work? I'm guessing it has to with the "-pe" options (which I know nothing about).
On Feb 25, 2006, at 12:32 AM, Oliver Taylor wrote:
Forgive the ignorance...
perl -pe ' s/"/"/g; '
This there any reason that the above wouldn't work? I'm guessing it has to with the "-pe" options (which I know nothing about).
It would probably help if you told us what you wanted it to do. I'm guessing you want it to replace all " with ", in which case you would want to escape the , i.e. s/"/\"/g
Haris
Charilaos Skiadas wrote:
On Feb 25, 2006, at 12:32 AM, Oliver Taylor wrote:
Forgive the ignorance...
perl -pe ' s/"/"/g; '
This there any reason that the above wouldn't work? I'm guessing it has to with the "-pe" options (which I know nothing about).
It would probably help if you told us what you wanted it to do. I'm guessing you want it to replace all " with ", in which case you would want to escape the , i.e. s/"/\"/g
It's just worth pointing out that it's the shell (bash) which is managing to strip out the backslashes, even inside single quotes. Perl's not to blame for once. :-)
-Dom
On 25/02/2006, at 17:20, Dominic Mitchell wrote:
It's just worth pointing out that it's the shell (bash) which is managing to strip out the backslashes, even inside single quotes. Perl's not to blame for once. :-)
Actually, bash doesn't escape anything in single-quotes and for that reason doesn't strip any backslashes either.
-- Sune.
On 25 Feb 2006, at 16:20, Dominic Mitchell wrote:
It's just worth pointing out that it's the shell (bash) which is managing to strip out the backslashes, even inside single quotes. Perl's not to blame for once. :-)
Don't think so. Try
$ echo '"'
and see what you get.
On Sat, Feb 25, 2006 at 05:52:03PM +0000, Andy Armstrong wrote:
On 25 Feb 2006, at 16:20, Dominic Mitchell wrote:
It's just worth pointing out that it's the shell (bash) which is managing to strip out the backslashes, even inside single quotes. Perl's not to blame for once. :-)
Don't think so. Try
$ echo '"'
and see what you get.
Doh. I'm thinking of this:
$ echo '''
-Dom
On 25.02.2006, at 07:32, Oliver Taylor wrote:
perl -pe ' s/"/"/g;
try to escape the backslash:
perl -pe 's/"/\"/g;'
works for me.
The meaning of the switches is (from `man perlrun`)
-p causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed:
LINE: while (<>) { ... # your program goes here } continue { print or die "-p destination: $!\n"; }
If a file named by an argument cannot be opened for some reason, Perl warns you about it, and moves on to the next file. Note that the lines are printed automatically. An error occurring during printing is treated as fatal. To suppress printing use the -n switch. A -p overrides a -n switch.
"BEGIN" and "END" blocks may be used to capture control before or after the implicit loop, just as in awk.
-e commandline may be used to enter one line of program. If -e is given, Perl will not look for a filename in the argument list. Multiple -e commands may be given to build up a multi-line script. Make sure to use semicolons where you would in a normal program.
Soryu.
On Feb 25, 2006, at 7:32, Oliver Taylor wrote:
Forgive the ignorance...
perl -pe ' s/"/"/g; '
This there any reason that the above wouldn't work? I'm guessing it has to with the "-pe" options (which I know nothing about).
In Perl the second half of s///, the replacement part, behaves like a double-quoted string so to speak. In particular you need to escape the backslash:
$ perl -pe 's/"/\"/g' file1 ... filen
-- fxn