Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Here documents in blocks

by Discipulus (Canon)
on Dec 19, 2020 at 17:07 UTC ( [id://11125457]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Here documents in blocks
in thread Here documents in blocks

Hello Bod,

this works

use strict; use warnings; print $_=<<" EOT"; indented as intended EOT exit;

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^4: Here documents in blocks
by Bod (Parson) on Dec 19, 2020 at 17:11 UTC
    this works

    But this doesn't...

    use strict; if (1) { print<<" END"; Here is some text which needs to be flush to the left margin END }

    It works in the sense it compiles and runs but doesn't do as intended.

      This one?
      use strict; if (1) { $_=<<" END"; Here is some text which needs to be flush to the left margin END s/^\s+//gm; print; }

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

        Adding another bit:

        if (1) { $_= <<" END"; Here is some text which needs to be flush to the left margin and has indented parts END /^(\s*)/; print s/^$1//gmr; }

        Update:
        Here is another one:

        if (1) { print <<" EOT" =~ s/^(\s*)//r =~ s/^$1//gmr; Here is some text which needs to be flush to the left margin and has indented parts EOT }

        Greetings,
        -jo

        $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-18 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found