Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Dynamically creating a format definition?

by traveler (Parson)
on Dec 13, 2001 at 20:58 UTC ( [id://131659]=note: print w/replies, xml ) Need Help??


in reply to Dynamically create a format definition

My second edition camel book shows how to do it. The critical points are: 1) put the output of the format statement into a variable, 2) eval that variable. Here is a piece of demonstration code. I have tried to make it readable, it is surely not the most compact version possible.
$data = qw( aaa bbb ccc ); $fields = scalar @data; $data_fields = ""; map $data_fields .= '"' . $_ . '"', @data; $format = "format STDOUT = \n" . "@<<< " x $fields . "\n" . $data_fields . "\n"; . ".\n"; eval $format; write;
HTH, --traveler

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://131659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-18 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found