Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > format/write question

Reply
Thread Tools

format/write question

 
 
Steve K.
Guest
Posts: n/a
 
      08-16-2007
I seem to be having a difficult time understanding formats. I've figured
out how to use formline easy enough, but when trying to test format and
write, using an example from perldoc perlform, it hangs, unless I
comment out the line with the call to write. If I uncomment it, the
program hangs and eats more and more CPU. I don't see how this can be
for such a small program?


#!/usr/local/bin/perl

use strict;

our $text = "line 1\nline 2\nline 3";
format STDOUT =
Text: ^*
$text
~~ ^*
$text
 
Reply With Quote
 
 
 
 
Darren Dunham
Guest
Posts: n/a
 
      08-16-2007
Steve K. <(E-Mail Removed)> wrote:

> #!/usr/local/bin/perl
> use strict;


> our $text = "line 1\nline 2\nline 3";
> format STDOUT =
> Text: ^*
> $text
> ~~ ^*
> $text
> .



> write (STDOUT);


I don't see in the 5.6.1 documentation that ^* is supported. So it's
either not supposed to work in older versions, or it wasn't much used
and you've found an old bug.

99% of the formats I've seen and used just worked with simple
fixed-width fields.

> I'm also wondering why one would want to use them over printf/sprintf,
> especially when they seem to be so much trouble to use. It reminds me a
> little of Cobol.


Maybe you don't. But formats do understand line counts per page, so if
you're used to 66 line pages, they take a bit of work out. You'd have
to code some extra logic to do that with printf.

--
Darren Dunham http://www.velocityreviews.com/forums/(E-Mail Removed)
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
 
Reply With Quote
 
 
 
 
greymaus@spurious.com
Guest
Posts: n/a
 
      08-21-2007
On 2007-08-16, Darren Dunham <(E-Mail Removed)> wrote:
> fixed-width fields.
>
>> I'm also wondering why one would want to use them over printf/sprintf,
>> especially when they seem to be so much trouble to use. It reminds me a
>> little of Cobol.

>
> Maybe you don't. But formats do understand line counts per page, so if
> you're used to 66 line pages, they take a bit of work out. You'd have
> to code some extra logic to do that with printf.
>


format is a nice low-end word formatter, best used, AFAIknow, for
formatting data extracted with perl into a nicely formed and easily
read report. Pump it into TeX and use \verbatim{}. Filter out a data
field you want from the mass of data.


--
Greymaus
Just Another Grumpy Old man
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments