Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: 'return undef' as a "best practice" ('2 things at once with Class::Base')

by tye (Sage)
on Nov 02, 2007 at 17:16 UTC ( [id://648694]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub getFileSize
    {
        my( $fileName )= @_;
        return -s $fileName;
    }
    
  2. or download this
    sub getFileSize
    {
    ...
        }
        return $size;
    }
    
  3. or download this
        my $fileName= getFileName();
        my @size;
    ...
        } else {
            print "Can't determine file size for $fileName: $!\n";
        }
    
  4. or download this
        my %sizes= (
            $inputFile =>   getFileSize($inputFile),
            $controlFile => getFileSize($controlFile),
        );
    
  5. or download this
        my %object= (
            InputFile =>    $inputFileName,
    ...
            ControlSize =>  getFileSize($controlFileName),
        );
        return bless \%object;
    
  6. or download this
        my %sizes= (
            $inputFile =>   $controlFile,
    ...
            $controlFileName => "ControlSize",
        );
        return bless \%object;
    
  7. or download this
        my %sizes= (
            $inputFile =>   scalar -s $inputFile,
            $controlFile => scalar -s $controlFile,
        );
    
  8. or download this
        my @files= getFileNames();
    
    ...
    # or
        my %sizes;
        @sizes{@files}= map getFileSize($_), @files;
    
  9. or download this
        my @files= getFileNames();
        my @sizes;
        for my $fileName (  @files  ) {
            push @sizes, getFileSize( $fileName );
        }
    
  10. or download this
    sub missingIsSmallest
    {
    ...
        my @files= sort {
            missingIsSmallest( getFileSize($a), getFileSize($b) )
        }   getFileNames();
    
  11. or download this
        reportFile( $file, getFileSize($file), "Financials" );
    # or
    ...
            FileSize =>     getFileSize($file),
            Description =>  "Financials",
        );
    

Log In?
Username:
Password:

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

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

      No recent polls found