my $filename = $upload->file_name( 'fichier' ); my $type = $upload->file_type( 'fichier' ); my $file_handle = $upload->file_handle( 'fichier' ); #### sub file_XXXX { my $self = shift; my ($param) = @_; my $cgi = $self->{'_CGI'}; return undef unless defined $cgi->param($param); $self->{'_PARAMS'}->{$param} = $self->_handle_file( $cgi, $param) unless exists $self->{'_PARAMS'}->{$param}; return $self->{'_PARAMS'}->{$param}->{'file_XXXX'}; } #### my $object = { 'file_handle' => $fh, 'file_name' => $file[0] . $file[2], 'file_type' => substr(lc $file[2], 1), 'mime_type' => $magic->checktype_filehandle($fh) }; $fh->seek(0, 0); $fh->binmode if $CGI::needs_binmode; return $object; #### sub _handle_file { # ... more code fileparse_set_fstype( do { my $browser = HTTP::BrowserDetect->new; return 'MSWin32' if $browser->windows; return 'MacOS' if $browser->mac; $^O; } ); # ... more code } #### my $browser = HTTP::BrowserDetect->new; fileparse_set_fstype( $browser->windows ? 'MSWin32' : $browser->mac ? 'MacOS' : $^0 ); #### #!/usr/bin/perl -w use strict; sub test { my $arg = shift; my $x = foo ( do { # In theory, this will pass 7 to foo() if $arg is 3 # In reality, it will return from test() return 7 if $arg == 3; } ); $x = 5; return $x; } print test( 3 ),$/; print test( 5 ),$/; sub foo {};