Re: Format Question
- From: tom@xxxxxxxxxxxxxx (Tom Phoenix)
- Date: Wed, 15 Aug 2007 08:49:33 -0700
On 8/15/07, Mathew Snyder <theillien@xxxxxxxxx> wrote:
How would I go about sub-listing something. For instance, if I have a work
order that has been worked on during different days, I want to list the work
order once and each day below it. It would look like this:
Ticket ID Subject Date hh:mm
--------------------------------------------------------
12345 Ticket Subject MM/DD/YYYY 1:00
MM/DD/YYYY 2:00
MM/DD/YYYY 3:00
So basically, I need the ID and Subject to only be printed on the first line and
only the Date and hh:mm on each successive line. How would I do this with
format? Would I need two different formats? One for the first line and another
for each subsequent line?
There may be a simpler way. For example, if you're willing to use the
destructive caret, you could write a format including something like
this:
^>>>>> ^>>>>>>>>>>>>>>>>>>>>> @>/@>/@>>> @>:@>
$ticket_id_copy, $ticket_subject_copy, $month, $day, $year, $hour, $minute
(And do you really need to use the ambiguous format MM/DD/YYYY instead
of the logical descending order of YYYY/MM/DD?)
When you refill the two _copy variables, they'll be consumed on the next write.
But the simplest way of all may be to avoid using formats. Formats are
wonderful when they do what you want, they do all that you want, and
they can do all you will ever want. But if you will ever want more
than formats can give you, you'll find yourself ripping out the output
code of your program and re-writing it from scratch. That's the
heartbreak of formats.
It may be that you're able to do all you want with formats; there are
a lot of tricks out there. But in the long run, formats may or may not
be the easy way to get the job done.
Good luck with it!
--Tom Phoenix
Stonehenge Perl Training
.
- Follow-Ups:
- Re: Format Question
- From: Mathew Snyder
- Re: Format Question
- References:
- Format Question
- From: Mathew Snyder
- Format Question
- Prev by Date: Re: Read only part of file
- Next by Date: Re: die and exit
- Previous by thread: Format Question
- Next by thread: Re: Format Question
- Index(es):
Relevant Pages
|