Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: How to print two different formats to same file without getting an error?

by Jim (Curate)
on Feb 05, 2014 at 23:38 UTC ( [id://1073631]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to print two different formats to same file without getting an error?
in thread [SOLVED] How to print two different formats to same file without getting an error?

I can't test this refactored version of your script because, as toolic pointed out earlier, it's not a complete computer program.

use strict; use warnings; use autodie qw( open close ); use English qw( -no_match_vars ); my %households; my $household; my $first_name; my $last_name; my $voter_rating; my $support_level; my $phone_number; format Household = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $household ================================== . format Voter = @<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<< @<< @<<<<<<<<<<<< $last_name, $first_name, $voter_rating, $phone_number . open my $fh, '>encoding(ISO-8859-1)', 'out.txt'; select $fh; for $household (sort keys %households) { local $FORMAT_NAME = 'Household'; write; for my $member (@{ $households{$household} }) { $first_name = $member->{first_name}; $last_name = $member->{last_name}; $voter_rating = $member->{voter_rating}; $support_level = $member->{support_level}; $phone_number = $member->{mobile_number} // $member->{phone_n +umber} // ''; local $FORMAT_NAME = 'Voter'; write; } } close $fh; exit 0;

Jim

  • Comment on Re^3: How to print two different formats to same file without getting an error?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found