Fixed: typos and suchlike in Intro.pod
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Manual / Cookbook.pod
index 2c126d1..c18243d 100644 (file)
@@ -87,19 +87,20 @@ Catalyst Controller module 'upload' action:
 
     sub upload : Global {
         my ($self, $c) = @_;
-        if ($c->req->parameters->{form_submit} eq 'yes') {
-            my $upload = $c->req->upload('my_file');
-            if ($upload->filename) {
+
+        if ( $c->request->parameters->{form_submit} eq 'yes' ) {
+
+            if ( my $upload = $c->request->upload('my_file') ) {
+            
                 my $filename = $upload->filename;
-                my $fh = $upload->fh;
-                open(NEW_FILE, ">/tmp/upload/$filename") or die
-                    "Can't open file for writing: $!";
-                while ($fh->read(my $buf, 32768)) {
-                    print NEW_FILE $buf;
+                my $target   = "/tmp/upload/$filename";
+                
+                unless ( $upload->link_to($target) || $upload->copy_to($target) ) {
+                    die( "Failed to copy '$filename' to '$target': $!" );
                 }
-                close(NEW_FILE);
             }
         }
+        
         $c->stash->{template} = 'file_upload.html';
     }
 
@@ -122,21 +123,20 @@ Controller:
 
     sub upload : Local {
         my ($self, $c) = @_;
-        if ($c->req->parameters->{form_submit} eq 'yes') {
-            for my $field ($c->req->upload) {
-                my $upload = $c->req->upload($field);
-                if ($upload->filename) {
-                    my $filename = $upload->filename;
-                    my $fh = $upload->fh;
-                    open(NEW_FILE, ">/tmp/upload/$filename") or die
-                        "Can't open file for writing: $!";
-                    while ($fh->read(my $buf, 32768)) {
-                        print NEW_FILE $buf;
-                    }
-                    close(NEW_FILE);
+
+        if ( $c->request->parameters->{form_submit} eq 'yes' ) {
+
+            for my $field ( $c->req->upload ) {
+
+                my $filename = $upload->filename;
+                my $target   = "/tmp/upload/$filename";
+                
+                unless ( $upload->link_to($target) || $upload->copy_to($target) ) {
+                    die( "Failed to copy '$filename' to '$target': $!" );
                 }
             }
         }
+
         $c->stash->{template} = 'file_upload.html';
     }
 
@@ -283,8 +283,8 @@ And this is all you need to do, isn't Catalyst wonderful?
 
 Catalyst applications give optimum performance when run under mod_perl.
 However sometimes mod_perl is not an option, and running under CGI is 
-just too slow.  There are two alternatives to mod_perl that give 
-reasonable performance: FastCGI and PersistentPerl.
+just too slow.  There's also an alternatives to mod_perl that gives
+reasonable performance named FastCGI.
 
 B<Using FastCGI>
 
@@ -341,44 +341,6 @@ authentication, authorization and access check phases.
 For more information see the FastCGI documentation, the C<FCGI> module 
 and L<http://www.fastcgi.com/>.
 
-
-B<PersistentPerl>
-
-PersistentPerl (previously known as C<CGI::SpeedyCGI>) is a persistent 
-Perl interpreter.  After the script is initially run, instead of 
-exiting, the perl interpreter is kept running. During subsequent runs, 
-this interpreter is used to handle new executions instead of starting 
-a new perl interpreter each time. A very fast frontend program contacts
-the persistent Perl process, which is usually already running, to do 
-the work and return the results.
-PersistentPerl can be used to speed up perl CGI scripts.  It also 
-provides an Apache module so that scripts can be run without the 
-overhead of doing a fork/exec for each request.
-
-The code for PersistentPerl is simpler than for FastCGI; rather than 
-waiting in an accept loop the script runs to completion, however 
-variables are not reinitialized on subsequent runs but maintain their 
-values from the previous run.
-
-
-    #!/usr/bin/perperl
-    use strict;
-    use vars qw($output $initialized);
-    use PersistentPerl;
-    use MyApp;
-
-    if (!$initialized++) {
-        # initialization code - set up database, etc
-        if ($PersistentPerl::i_am_per_perl) {
-            # PP-specific initialization code
-        }
-    }
-
-    MyApp->run;
-
-For more information see the C<PersistentPerl> documentation.
-
-
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@oook.de>