Re: Perl equivalent to unix script



Mike wrote:

cat tempfile1 | sort > newfile2;

That's rather convoluted even for UNIX scripting. Why not:

sort tempfile1 > newfile2;

You cannot do this as a pure-Perl approach (ie, no shell redirects,
etc) any more simply. You could do something like this:

#!/usr/bin/perl
use strict; use warnings;

open (my $in, '<', '/tmp/tempfile1') or die "oops - $!\n";
open (my $out, '>', '/tmp/newfile2') or die "oops - $!\n";

print $out sort(<$in>);

close $in;
close $out;

unlink $in;

__END__

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

.