http://qs321.pair.com?node_id=738356


in reply to Re: Simulate a head lice infection
in thread Simulate a head lice infection

Hmm, you say "less noisily using a heredoc", I say "mess up tabbing of the file making it look ugly".

Maybe use say instead of print, and use commas instead of ; print -- that may look less noisy and save the tabs.

Iono, its just an annoyance I have with heredoc.

And you didn't even know bears could type.

Replies are listed 'Best First'.
Re^3: Simulate a head lice infection
by johngg (Canon) on Jan 23, 2009 at 22:57 UTC

    One way you can indent HEREDOCs is to substitute the leading spaces in a map.

    $ perl -e ' $x = 1; if( $x ) { print map { s{^ }{}gm; $_ } <<" EOT"; Line 1 Line 2 \$x is $x Line 4 EOT }' Line 1 Line 2 $x is 1 Line 4 $

    This really is not a serious suggestion. It is rather horrible, probably inefficient and it would be a nightmare to maintain in a script. It would easily break if code is moved around and logical depth (thus indentation) changes or if you use an editor that decides off its own bat to use tabs instead of spaces when auto-indenting.

    I just post the code as a curio. Downvote if nauseated.

    Cheers,

    JohnGG