> Randal L. Schwartz writes: > |>>>>> "L" == L <Brian> writes: > |L> Actually writing formatted text to a variable. And to be somewhat fair, > |L> that's about the only way to do it in base perl4. > |Well, not without forking. :) > > I thought of that, but consider it basically the same as the example given: > whether the intermediary is a pipe or a temp file, write to some filehandle, > then read the formatted text. With the temp file you need to clean up the > file while pipes go away on their own, but forking doesn't work with perls > that don't fork. Aha! This is a *perfect* opportunity to use `the secret passage'. People who don't know about that yet might enjoy trying running it and trying to figure out what is going on. Spoilers are at http://www.plover.com/~mjd/perl/LOD/#9 The following program works but does not use either a temporary file or `fork': #!/usr/bin/perl format OUT = @<<<<<<<<< | @|||||||||| | @>>>>>>>>>> @#####.## $left, $center, $right, $numeric . $numeric = 11; unless ($ARGV[0] eq 'receive') { close STDIN or die "close STDIN: $!"; pipe(STDIN, OUT) or die "pipe: $!"; for ($i=0; $i<7; $i++) { ($left, $center, $right) = split /\s+/, scalar <DATA>; write OUT; $numeric *= 2 / 3; } close OUT; exec "./$0 receive"; die "exec: $!"; } # Read formatted data from standard input print "STDIN $.: $_" while <STDIN>; __DATA__ In the beginning God created the heavens and the Earth. The Earth was without form and void, and darkness was upon the face of the deep. ==== Want to unsubscribe from this list? (Don't you love us anymore?) ==== Well, if you insist... Send mail with body "unsubscribe" to ==== fwp-request@technofile.org