From: Ela on
I found that little can be done on debugging a variable on print, after
visiting a page containing the module PadWalker.

I wonder whether in Perl can do something like:

$newline = '\n'

print
foo
$foo

print $newline;


I use the vim editor, in this sense, rapid coding and debugging can achieve.
But i at least know that the newline trick doesn't work...


From: David Filmer on
Ela wrote:
> $newline = '\n'

In Perl, single-quotes are not interpolated (meaning $newline is set to
backslash-n). You would need to use double-quotes (or qq{}) to
interpolate \n as a newline.
From: szr on
David Filmer wrote:
> Ela wrote:
>> $newline = '\n'
>
> In Perl, single-quotes are not interpolated (meaning $newline is set
> to backslash-n). You would need to use double-quotes (or qq{}) to
> interpolate \n as a newline.

Or a heredoc :-)

print <<_EOF_;
$foo $bar
_EOF_

--
szr


From: Ela on
> Or a heredoc :-)
>
> print <<_EOF_;
> $foo $bar
> _EOF_
>
> --
> szr
>

There are too few words in your example and I'm unable to follow/Google. I
guess maybe you are telling something important? thx


From: David Filmer on
Ela wrote:
>> Or a heredoc :-)
>>
>> print <<_EOF_;
>> $foo $bar
>> _EOF_
>>
>
> There are too few words in your example and I'm unable to follow/Google. I
> guess maybe you are telling something important? thx

szr is just showing you an example of how to use a heredoc, which
recognizes the \n at the end of any lines within it (so it's just
another way of printing newlines).

You could do the same thing like this:

print "$foo $bar
";

but that's questionable programming style (whereas a heredoc is
generally accepted, though I personally dislike them).