On Thu, Feb 12, 2009 at 06:47, Rob Dixon <rob.di...@gmx.com> wrote:
snip
> The sequence starting with <<EOF is a 'here document'. Perl has them too, but 
> in
> this case it is a Unix here-document which is process by the command shell.
> Before the command is actioned the sequence is replaced by the text between
> <<EOF and EOF. Unix is not my primary platform, but I would have thought the
> code you show was equivalent to
>
>  my $Tmpstr = `$path $HOME/bin/crypt -e -f $_keyfile$str\n`;
>
> I am sure others will correct me if I am wrong.
snip

A heredoc in (at least) the Bourne (sh), Korn (ksh), and Bourne Again
(bash) shells* is not a string like it is in Perl; it is a file that
is redirected into STDIN.  So

program <<ENDHEREDOC
foo
bar
baz
ENDHEREDOC

is the same as

echo "foo
bar
baz" > /tmp/somerandomname
program < /tmp/somerandomname

or

echo "foo
bar
baz" | program


* csh and its spawn can rot in the hell that spawned them, so I am not
certain if they even support heredocs and most of the other shells
like nash, zsh, busybox, etc. claim sh in their descent, so they
should treat heredocs in the same way.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to