[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: here document and STDIN

From: Cai Qian
Subject: Re: here document and STDIN
Date: Tue, 23 May 2006 19:08:50 +0100

The information is helpful. The problem by using

perl -e '

is that there seems no way to using single quota in Perl code any more.

On 5/23/06, Paul Jarc <address@hidden> wrote:
"Cai Qian" <address@hidden> wrote:
> For following code,
> sh <<EOF
>       read
> I have no idea why will not block.

The "read" command reads from the shell's stdin, which is the here
document.  At the point where the "read" command is executed, the
shell has already read the "read" command from the here document, so
the next thing read from there will be end-of-file.  If you want the
"read" command to read from the original stdin that was present before
the here document was introduced, you can copy it to another

sh <<EOF 3<&0
    read <&3

> So I can run some Perl code inside like,
> perl - <<'EOF'
>      XXXXX

With perl, it may be easier to use -e instead of a here document:
perl -e '

Then perl will still be connected to the original stdin, without any
need for duplicating descriptors.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]