home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!agate!stanford.edu!leland.Stanford.EDU!leland!filo
- From: filo@pegasus.Stanford.EDU (David Filo)
- Newsgroups: comp.lang.perl
- Subject: Help with quotes
- Message-ID: <FILO.92Nov4211406@pegasus.Stanford.EDU>
- Date: 5 Nov 92 05:14:06 GMT
- Sender: news@leland.Stanford.EDU (Mr News)
- Reply-To: filo@pegasus.stanford.edu
- Distribution: comp
- Organization: Stanford University
- Lines: 30
-
- I'm having a bit of a problem with quoting.
-
- This works as expected. It replaces the first character with a double-
- quote.
-
- $ perl -pe 's/./sprintf ("\\"")/e; print "<$@>" if $@'
- help
- "elp
- $
-
- Below is the same thing except $& has been added to the sprintf. In
- this case the evaluation of the replacement string fails. I have not
- been able to find a way to properly escape the double-quote to be
- printed.
-
- $ perl -pe 's/./sprintf ("$&\\"")/e; print "<$@>" if $@'
- help
- <EOF in string at (eval) line 1, <> line 1.
- >elp
- $
-
- I know I could just changes quote characters, but I need a way to
- include the quote character inside the quoted string.
-
- Any help on this would be greatly appreciated.
-
- Thanks,
-
- David Filo
- filo@pegasus.stanford.edu
-