On Jan 29, Thunem, Tom said:

>can anyone tell me how to toggle between 2 different formats writing to the
>same output filehandle?  i am not having luck with coding the select and
>write statements.

By default, the format for any given filehandle has the same name as the
filehandle itself.  To change that, select() the filehandle to work with,
and set $~ to the format name.

  format FOO =
  Name: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   Age: @##
        $name,                                       $age
  .

  format BAR =
  Occupation: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   Years Exp.: @#
              $occup,                                       $exp
  .

  select RECORD;
  $~ = "FOO";
  write;  # writes format FOO to RECORD
  $~ = "BAR";
  write;  # writes format BAR to record

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to