Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!snorkelwacker!think!zaphod.mps.ohio-state.edu!uwm.edu!wuarchive!decwrl!sun-barr!newstop!texsun!convex!convex.com!tchrist From: tchrist@convex.com (Tom Christiansen) Newsgroups: comp.lang.perl Subject: dynamic formats Message-ID: <5195@convex.convex.com> Date: 6 Feb 90 17:39:37 GMT Sender: news@convex.com Reply-To: tchrist@convex.com (Tom Christiansen) Organization: Convex Computer Corp, Richardson, TX Lines: 62 I've been using formatted writes and I find that it's a real pain to be forced to associate one sole format() with a given output channel. I've tried Johan Vromans's indirect-thru- a-subroutine work-around: format = @<<< @<<< @<<< @<<< $_[0], $_[1], $_[2], $_[3] . sub fmt_write { write; } &fmt_write("A", 1, 2, 3); which works ok, but not quite what I'd like. I think what I'd most like is something just *mildly* more similar to FORTRAN's write statements. I'd like to be able to dynamically specify *which* format to use. The documentation on format has format NAME picture . When you first look at that, you figure you should be able to use: format FOOFORM blah . write FOOFORM; # use FOOFORM to write to current output channel except that NAME really means a FILEHANDLE in this case. Formats don't really have their own namespace, and I wish they did. I'm trying to figure out a way to extend the syntax without breaking anything. If write's syntax were write(FILEHANDLE); or write(FILEHANDLE, FORMAT); where FORMAT were the name of a tagged format field, it could work. (Assume either FILEHANDLE or FORMAT could be scalar expressions for indirection.) But how to tag the format? We (probably) can't use format TAG because you couldn't (easily) disambiguate the TAG from a FILEHANDLE. Comments, criticisms, or inspirations anyone? --tom -- Tom Christiansen {uunet,uiucdcs,sun}!convex!tchrist Convex Computer Corporation tchrist@convex.COM "EMACS belongs in : Editor too big!"