Help for this page

Select Code to Download


  1. or download this
    use File::Slurp 'read_file';
    
    my @data = map { [ read_file( $_, chomp => 1 ) ] } 'file1', 'file2';
    print "$data[0][$_] = $data[1][$_]\n" for 0 .. $#{$data[0]};
    
  2. or download this
    my @data = map { [ read_file( $_, chomp => 1 ) ] } 'file1', 'file2';
    print map {
      length $data[0][$_] ? "$data[0][$_] = $data[1][$_]\n" : ''
    } 0 .. $#{$data[0]};
    
  3. or download this
    use File::Slurp 'read_file';
    use List::MoreUtils 'pairwise';
    ...
    print
      &pairwise( sub { length $a ? "$a = $b\n" : () },
        map { [read_file($_,chomp=>1)] } 'file1', 'file2' );