in reply to Shell v Perl, here-doc as stdin

You can do the same 'here document' style thing in perl...

print <<"EOF"; EOF # to pass the here document as stdin to some system # command you could do this: open(CMD,"| command"); print CMD <<"END"; stuff.... END close(CMD);

We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re: Re: Shell v Perl
by Improv (Pilgrim) on Apr 10, 2003 at 16:57 UTC
    It's worthwhile to note that in your example, the quotes around EOF are optional. Also, that there can be no whitespace seperating the << from the ending token. It's very easy to accidentally get that wrong, e.g.
    print << FOO; # WRONG!
    print <<FOO; # right
    
      You can doesn't mean you should. Perl6 will do away with that, thankfully.

      Makeshifts last the longest.