#!/bin/perl use v5.14; use warnings; use Path::Tiny; my $in = $ARGV[0] or die "Usage: $0 "; path($in)->copy($in =~ s/(\.\w+)?$/.out/r); __END__ #### #!/bin/perl use v5.14; use warnings; use Path::Tiny; my $in = $ARGV[0] or die "Usage: $0 "; my $out = path($in =~ s/(\.\w+)?$/.out/r); for my $line ( path($in)->lines({ chomp => 1 }) { # do something interesting with the line $out->append("$line\n"); } __END__