|
From: Ela on 2 Apr 2008 02:57 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' 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 2 Apr 2008 03:06 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 2 Apr 2008 12:11 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 2 Apr 2008 12:20 > 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 2 Apr 2008 13:28 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).
|
Next
|
Last
Pages: 1 2 Prev: ID3v2 cover art insertion with Perl? Next: FAQ 8.11 How do I decode encrypted password files? |