Printing angle brackets in Perl
I'm using a (pre-existing) script to generate a text file. In fact, it's a C++ header file. At the top of the file I'd like to add this text, which can be added by passing a parameter (to the script) called --fhead:-
Code:
#ifndef (__ATK_H_INSIDE__)
#error "Only <atk.h> can be included directly."
#endif
I'm not having any problems with the first line or the last line but in the middle line, those angle brackets are causing a problem. I can work around it by using quote marks, instead of the angle brackets. For example, this wouldn't (ordinarily) print from the Perl script:-
Quote:
perl the_script.pl --fhead "#error "Only "atk.h" can be included directly.""
But if I format the text properly - i.e.
Quote:
perl the_script.pl --fhead "#error \"Only \"atk.h\" can be included directly.\""
I get this in the eventual file:-
Quote:
#error "Only "atk.h" can be included directly."
If all else fails, the above would be acceptable - but ideally, I'd prefer to have angle brackets - i.e.
Quote:
#error "Only <atk.h> can be included directly."
My problem is that I can't find any way to format the text such that the angle brackets get considered as part of the text (rather than instructions to the Perl interpreter).
Any ideas, anyone... :confused:
Re: Printing angle brackets in Perl
Groan.... I think this might be a problem with the script iself... :(
I wrote this very simple Perl script and all four lines printed out exactly as expected:-
Code:
#! e:/program files/perl/bin/perl.exe
print "Hello World\n";
print "\"Hello World\"\n";
print "<Hello World>\n";
print "\"<Hello World>\"\n";
Oh well, back to the drawing board... :cry: