Help for this page

Select Code to Download


  1. or download this
    sub getfile {
      my $filename = shift;
      open my $FH, "<$filename" or die "Unable to open $filename: $!";
      return wantarray ? map /(.*)/, <$FH> : do { local $/ ; <$FH> };
    }
    
  2. or download this
    sub getfile { local *ARGV ; @ARGV = shift ; wantarray ? map /(.*)/, <>
    + : do { local $/ ; <> } }
    
  3. or download this
    sub getfile {
      my $filename = shift;
    ...
    
      return wantarray ? split m{$/}, $contents : $contents;
    }