Greets all<br><br>So I have a interesting issue that I need some assistance with.<br><br>I found a here doc &quot;formatting&quot; function on-line (at CPAN) that claims to &quot;expect input from a here doc&quot;.<br>I&#39;ve made one little change to preserve &quot;blank lines&quot; (i.e, changed a couple &quot;\s&quot; to &quot;[\t ]&quot;), hence the <br>
function name.<br><br>Now I  want to offload it into a require file.  however &quot;perl -c&quot; fails when doing so.<br><br>--------[ code #1: file1.pl ]-------------<br>sub dequote_blank_lines<br>{<br>    local $_ = shift;<br>
    my ($white, $leader);  # common white space and common leading string<br>    if (/^[\t ]*(?:([^\w\s]+)(\s*).*\n)(?:\s*\1\2?.*\n)+$/) {<br>        ($white, $leader) = ($2, quotemeta($1));<br>    } else {<br>        ($white, $leader) = (/^([\t ]+)/, &#39;&#39;);<br>
    }<br>    s/^[\t ]*?$leader(?:$white)?//gm;<br>    return $_;<br>}<br><br>   $cde_script = dequote_blank_lines &lt;&lt;_EOF_;<br>           #!/bin/sh<br>      <br>           #real code removed for brevity<br>           /usr/bin/echo &quot;Hello World&quot;<br>
<br>_EOF_<br><br>   print $cde_script<br><br>In this first snippet everything works fine.  and a &quot;perl -c&quot; returns OK. <br>Now lets offload to a require file:<br><br><br>--------[ code #2: file2.pl ]-------------<br>

sub dequote_blank_lines<br>
{<br>
    local $_ = shift;<br>
    my ($white, $leader);  # common white space and common leading string<br>
    if (/^[\t ]*(?:([^\w\s]+)(\s*).*\n)(?:\s*\1\2?.*\n)+$/) {<br>
        ($white, $leader) = ($2, quotemeta($1));<br>
    } else {<br>
        ($white, $leader) = (/^([\t ]+)/, &#39;&#39;);<br>
    }<br>
    s/^[\t ]*?$leader(?:$white)?//gm;<br>
    return $_;<br>
}<br>
<br>1;<br><br>--------[ code #2: file3.pl ]-------------<br><br>   require &quot;file2.pl&quot;;<br><br>
   $cde_script = dequote_blank_lines &lt;&lt;_EOF_;<br>
           #!/bin/sh<br>
      <br>
           #real code removed for brevity<br>
           /usr/bin/echo &quot;Hello World&quot;<br>
<br>
_EOF_<br>
<br>
   print $cde_script<br><br>In this case, file3.pl fails syntax check in every way imaginable.<br><br>I have tried prototyping the function: sub dequote_blank_lines ($), but this fails too.<br>I am not opposed to making this routine work like a real function and change it to:<br>
<br><div style="margin-left: 40px;">$cde_script = HERE_DOC; # for brevity<br>$cde_script = &amp;dequote_blank_lines($cde_script);<br></div><br>But, I am one who likes flexibility and I think it should work either way.  And I am trying <br>
to maintain the original intent of the subroutine, expecting a here doc<br><br><br><br clear="all">Chad, CISSP<br><a href="http://www.brainyquote.com/quotes/authors/j/jack_benny.html" target="_blank">Jack Benny</a>  - &quot;I don&#39;t deserve this award, but I have arthritis and I don&#39;t deserve that either.&quot;