1 package TestApp::Controller::Engine::Response::PerlIO;
4 use base 'Catalyst::Controller';
9 use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
11 my $data1 = 'x' x (100 * 1024);
12 #my $data2 = join '', map { chr($_) } (0..65535);
13 my $data2 = join('', map { chr($_) } (0..255)) x 256;
15 my $zip = new Archive::Zip;
16 $zip->addString(\$data1, 'x.txt', COMPRESSION_LEVEL_BEST_COMPRESSION);
17 #$zip->addString(\$data2, 'utf16.txt', COMPRESSION_LEVEL_BEST_COMPRESSION); ### Needs better support in Archive::Zip first... ###
18 $zip->addString(\$data1, 'ASCII.txt', COMPRESSION_LEVEL_BEST_COMPRESSION);
20 unless ($zip->writeToFileHandle($c->response, 0) == AZ_OK) {
21 Catalyst::Exception->throw("ZIP Write Error!");
26 my ( $self, $c ) = @_;
30 my $csv = Text::CSV->new({ eol => "\n" });
33 [1, "Box of Ritz Crackers", '$2.55'],
34 [1, "Cheese Whiz", '$1.22'],
35 [5, "Banana (single)", '$ .40'],
38 while (my $row = shift @$csv_doc) {
39 $csv->print($c->response, $row) || Catalyst::Exception->throw("CSV Write Error!");
44 my ( $self, $c ) = @_;
48 my $xs = XML::Simple->new(
51 OutputFile => $c->response,
57 address_components => [
61 types => [ "street_number" ]
64 long_name => "Amphitheatre Pkwy",
65 short_name => "Amphitheatre Pkwy",
69 long_name => "Mountain View",
70 short_name => "Mountain View",
71 types => [ "locality", "political" ]
74 long_name => "Santa Clara",
75 short_name => "Santa Clara",
76 types => [ "administrative_area_level_2", "political" ]
79 long_name => "California",
81 types => [ "administrative_area_level_1", "political" ]
84 long_name => "United States",
86 types => [ "country", "political" ]
90 short_name => "94043",
91 types => [ "postal_code" ]
94 formatted_address => "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
100 location_type => "ROOFTOP",
103 lat => 37.42244328029150,
104 lng => -122.0839025197085
107 lat => 37.41974531970850,
108 lng => -122.0866004802915
112 types => [ "street_address" ]
116 source => 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false'
118 }) || Catalyst::Exception->throw("XML Write Error!");