CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    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:-

    perl the_script.pl --fhead "#error "Only "atk.h" can be included directly.""
    But if I format the text properly - i.e.

    perl the_script.pl --fhead "#error \"Only \"atk.h\" can be included directly.\""
    I get this in the eventual file:-

    #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.

    #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...
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    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...
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured