using Print << marker with require statement?

Discussion in 'Perl Misc' started by me, Mar 26, 2010.

  1. me

    me Guest

    A noob question about using a require statement. I tried including a
    file that looks like this:

    print << "endOfText";
    Sample Text
    endOfText

    This works fine in the main program but if I put it in a separate file
    and include it with a require statement, it fails with the message
    "Can't find string terminator "endOfText" anywhere before EOF at
    test-require.pl line 1.

    There must be some Perl subtlety that I am missing.

    Thanks,
     
    me, Mar 26, 2010
    #1
    1. Advertising

  2. me

    Guest

    On Fri, 26 Mar 2010 14:37:27 -0400, me <> wrote:

    >A noob question about using a require statement. I tried including a
    >file that looks like this:
    >
    > print << "endOfText";
    > Sample Text
    > endOfText
    >
    >This works fine in the main program but if I put it in a separate file
    >and include it with a require statement, it fails with the message
    >"Can't find string terminator "endOfText" anywhere before EOF at
    >test-require.pl line 1.
    >
    >There must be some Perl subtlety that I am missing.
    >
    >Thanks,


    Try this, it might be looking for newline embedded markers:
    "\nendOfText\n";

    use strict;
    use warnings;

    print << "endOfText";
    Sample Text
    endOfText
    endOfText

    __END__

    -sln
     
    , Mar 26, 2010
    #2
    1. Advertising

  3. me

    Guest

    On Fri, 26 Mar 2010 14:37:27 -0400, me <> wrote:

    >A noob question about using a require statement. I tried including a
    >file that looks like this:
    >
    > print << "endOfText";
    > Sample Text
    > endOfText
    >
    >This works fine in the main program but if I put it in a separate file
    >and include it with a require statement, it fails with the message
    >"Can't find string terminator "endOfText" anywhere before EOF at
    >test-require.pl line 1.
    >
    >There must be some Perl subtlety that I am missing.
    >
    >Thanks,


    Its looking for newline delimeted string.
    In your body it is
    \n' endOfText'\n
    If you want to leave it that way then put
    any body spaces after the first newline and
    before the last newline.


    print << " endOfText";
    Sample Text
    endOfText

    -sln
     
    , Mar 26, 2010
    #3
  4. me

    me Guest

    On Fri, 26 Mar 2010 19:40:52 +0000, Ben Morrow <>
    wrote:

    >Works for me, so there must be something you're not telling us. I
    >prseume your example above is indented for the benefit of Usenet, and
    >'endOfText' is actually at the start of the line? It needs to be.


    Yes... all statements are actually left justified. Any other ideas?
    The code works fine within a program, and other code I "require" also
    works fine.

    >If you are trying to use this for templating, there are better
    >approaches. Search the group (or search.cpan.org) for 'template' to get
    >some suggestions.


    Understood. At this point I'd just like to understand why this code
    does not work.
     
    me, Mar 30, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Henry

    top level marker?

    Brian Henry, Dec 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    374
    Brian Henry
    Dec 27, 2003
  2. =?Utf-8?B?V2FubmFiZV9HZWVr?=

    Marker in ASP.Net

    =?Utf-8?B?V2FubmFiZV9HZWVr?=, May 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    622
    Alvin Bruney [MVP - ASP.NET]
    May 14, 2005
  3. X_AWieminer_X
    Replies:
    2
    Views:
    12,410
    JomoFrodo
    Aug 18, 2011
  4. pentium
    Replies:
    3
    Views:
    421
    bilbo
    Nov 22, 2004
  5. Replies:
    0
    Views:
    274
Loading...

Share This Page