LPM: filtering

Frank Price fprice at mis.net
Tue Mar 7 14:18:41 CST 2000


On Tue, 7 Mar 2000, Joe Hourcle wrote:

# On Tue, 7 Mar 2000, Frank Price wrote:
# 
# > Hi LexPM,
# > 
# > I want to text-wrap a string to 50 columns before printing it to
# > sendmail.  In the shell, I'd do this:  
# > 
# >   echo "Really long string ..." | fmt -50 | mail 
# > 
# > How can I do the same in perl?  I tried something like the following,
# > essentially from the Cookbook, but it just printed to my terminal's
# > stdout and then hung until I ctrl-D.  I realize I could use a temp
# > array to hold the formatted output, but for some reason this seems
# > more "elegant" -- is there any way to make it work?
# 
# I've never used it, but both the format command, and Text::Wrap chould do
# it..
# 
# using Text::Wrap, it'd be something like this:

Yah, I know about Text::Wrap, and it works great.  Seemed a shame to
load a module just for that if I could roll my own though (although
forking might be just as bad).  

Anyway, a more abstract version of my question is:  Can I pipe to a
program, print to it, and then read from that stdout so I can do
something else with it?  The "fork off another process" idea from the
Cookbook seems to be what I want, but something's going wrong.

-Frank.
--
Frank Price											fprice at mis.net
E Pluribus Unix | Linux: Choice of a GNU Generation | Why not go mad?





More information about the Lexington-pm mailing list