-----Original Message----- From: owner-cgi-list@jann.com [mailto:owner-cgi-list@jann.com]On Behalf Of Stephen Martin Sent: Thursday, November 08, 2001 1:32 PM To: Cgi-List@Jann.Com Subject: [CGI] format Hello, recently a fellow perl coder told me that format NAME @<<<<< $blah . was a depreciated feature? Is this true? If so.. what should I replace such constructs with? Well, if it is of any comfort, "deprecated" doesn't mean "unavailable" or "unsupported". It means that the feature you are using will be phased out in newer versions of Perl. This pretty much applies to every type of software. This means that you've got a bit of time before you'll see any problems with your code, so that you have plenty of time to update it. Note that this isn't really an issue at all so long as you stick to the version of Perl which you are using at this time. Even now, I still haven't heard or read anything to the effect that Perl was going to phase out it's format data-type and its built-in function called format(). Understanding this, it is still a good idea to try and make your code as forward-compatible as possible. So Stephen, the way I've solved this problem myself is through the use of two or three other methods which mimic or replace the functionality of the format data-type and built-in function of Perl. The reasons I've tried to stay away from it in the past are not really any good ones, I guess -- I've just found it easier and less complicated than moving to a C-style variable interpolation mechanism for strings when Perl has its own native features which do a lot of the same things. (Interpolation means to stuff the value of a given variable into a block of text.) What you give up in some respects when using Perl's native string interpolation over the C-style, C-implemented format() function is the ability to get variable values that you stuff into the text block to do things like appear right-justified, justified, or truncated at a certain length without having to do anything tricky. The ability to do those things is however made possible in an easy and almost seemless manner through the use of one or a few text manipulation modules (code libraries) which come standard with your Perl distribution or may be downloaded from the CPAN. OK, so on to the few methods I use instead of format(). 1.) templates with embedded perl tokens. (it works like ASP, JSP, ColdFusion, and PHP) You can use my own Template::Parser module available at http://www.atrixnet.com/cgi-bin/archive.pl/pub/modules/Template/Parser.pm or other libraries which are more generic and probably more suited to a universal implementation at the CPAN. 2.) sprintf([template], [variable list]) This works much like format() does, but isn't really made for multi-line interpolation -- although it is possible. You can get the same types of text justification and truncation abilities as with format(). 3.) try Damian Conway's text::wrap module. I'm not sure if the name is capitalized or not, but it is easy to find at the CPAN. 4.) there's tons of other text manipulation libraries available for free at the CPAN which you can find easily by clicking over to http://search.cpan.org/ and selecting the category for text manipulation -- after all, text manipulation is one of the most powerful uses of Perl, and a main focus of its creator when Larry Wall first gave Perl to the world. Perl itself stands for "Practical extraction and reporting language" -- a name very indicative of its ability to do wild and crazy things with text. Tommy Butler Internet Strategies, Inc. Everything is Possible web http://www.istrat.com email mailto:tommy@istrat.com tel 214·393·1000 ext 207 fax 800·307·8105 2200 North Lamar, Suite 307 Dallas, TX 75202