use strict; use warnings; # open an input stream # same effect as: # cat /mnt/scripts/lagtime/tmp/input.txt| # if fail, print reason ($!) and abort open IN, '<', '/mnt/scripts/lagtime/tmp/input.txt' or die "Couldn't open input file: $!"; # open an output stream # same effect as: # > /tmp/snapvault_status.out.out; # if fail, print reason ($!) and abort open OUT, '>', '/tmp/snapvault_status.out.out' or die "Couldn't open output file: $!"; # equivalent to your awk program # { printf "%1.50s\t%0.60s\t%0.45s\t %0.45s\n", $1, $2, $3, $4 } while (my $line=) { # chomp: remove record separator # split: break into fields using default AWK field separator # (a single space which is equivalent to the Perl regex m{ } my @aFields = split(m{ }, $line); chomp $line; printf OUT "%1.50s\t%0.60s\t%0.45s\t %0.45s\n", @aFields }