#!/usr/bin/env perl use 5.012; use warnings; use autodie; use Getopt::Long; # Replace tabs with 4 spaces my $verbose = 0; GetOptions(verbose => \$verbose); die "Usage: $0 [--verbose] input_path output_path" if @ARGV != 2; map { die "$_ is not a directory, or does not exist\n" unless -d } @ARGV; my ($input, $output) = @ARGV; opendir my ($in_dir), $input; for (sort grep { -f "$input/$_" } readdir $in_dir) { say if $verbose; open my $in, '<', "$input/$_"; open my $out, '>', "$output/$_"; while (<$in>) { s/\t/ /sg; print $out $_; } close $in; close $out; } closedir $in_dir;