[TriLUG] was more uselessinfo/commentary, now more percise perl question.

Andrew Perrin andrew_perrin at unc.edu
Thu Mar 21 16:05:18 EST 2002


On Thu, 21 Mar 2002, John F Davis wrote:
> [snip]
> 
> I am familar with HERE documents.  Like I said, I did a similar thing in
> BASH as what I am
> doing in this perl script.  Also, the HERE document below was meant to be
> for the sfdisk
> not perl.
>

In both cases - perl and your bash script - the here doc is in the script,
not in sfdisk. bash reads it line-by-line and sends it to sfdisk, just as
perl does. But perl requires some more baggage to open and manage the
channel to sfdisk, which is why you need to explicitly open the file pipe
and print to it rather than using bash shorthand.
 
> For what it matters, Perl makes use of here documents. p67 of programming
> perl,
> perldoc -q HERE but it seems to only apply to stdout and not pipes to
> programs.

Well, not exactly. heredocs in perl can go anywhere you want them
to; they'll go to any file handle, including a pipe to a program.

> man perlipc doesn't even cover HERE docs.
>

That's because the here doc portion of your problem is irrelevant to
ipc; it's just a convenient way of writing a lot of print() statements.
 
> I'm rather disappointed that perl can't do this.  This seems to be rather
> simple.

It is, and it can, as you found out :)

Best,
A

----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
 Assistant Professor of Sociology, U of North Carolina, Chapel Hill
      269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA







More information about the TriLUG mailing list