Jan Eden wrote:
>
> this is not so much a technical as a stilistic question: How do you indent
> here-quoted parts? When writing code like this:
>
> foreach $letter ('a'..'z') {
> my $upletter = uc $letter;
> print ALPHAINDEX <<"EOF";
> <hr />
> <p><a name="${letter}link"></a>
> <b>$upletter</b>
> <a href="#Navbar"><img src="../../gifs/up.gif" alt="" border="0" width="12"
> height="15" /></a></p>
> <ul>
> EOF
>
> The tabs get printed into the filehandle ALPHAINDEX. But not indenting the
> here-quoted part makes the script less readable.
>
> Any suggestions? Thanks!
Hi Jan.
This is mentioned in 'Perl Cookbook' with a solution something like this:
sub undent {
my $str = shift;
$str =~ s/^\s+//gm;
$str;
}
foreach $letter ('a'..'z') {
my $upletter = uc $letter;
print ALPHAINDEX undent <<" EOF";
<hr />
<p><a name="${letter}link"></a>
<b>$upletter</b>
<a href="#Navbar"><img src="../../gifs/up.gif" alt="" border="0" width="12"
height="15" /></a></p>
<ul>
EOF
}
But the most awkward thing is that the target line has to have the right number of
spaces preceding
it in the string.
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>